java.awt.image.BufferedImage.copyData()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中java.awt.image.BufferedImage.copyData()方法的一些代码示例,展示了BufferedImage.copyData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedImage.copyData()方法的具体详情如下:
包路径:java.awt.image.BufferedImage
类名称:BufferedImage
方法名:copyData

BufferedImage.copyData介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

static BufferedImage deepCopy(BufferedImage bi) {
 ColorModel cm = bi.getColorModel();
 boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
 WritableRaster raster = bi.copyData(null);
 return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}

代码示例来源:origin: plantuml/plantuml

private static BufferedImage deepCopy(BufferedImage bi) {
    final ColorModel cm = bi.getColorModel();
    final boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
    final WritableRaster raster = bi.copyData(bi.getRaster().createCompatibleWritableRaster());
    return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
  }
}

代码示例来源:origin: magefree/mage

public static BufferedImage deepCopy(BufferedImage bi) {
  ColorModel cm = bi.getColorModel();
  boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
  WritableRaster raster = bi.copyData(null);
  return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}

代码示例来源:origin: nguyenq/tess4j

/**
   * Clones an image.
   * http://stackoverflow.com/questions/3514158/how-do-you-clone-a-bufferedimage
   *
   * @param bi
   * @return
   */
  public static BufferedImage cloneImage(BufferedImage bi) {
    ColorModel cm = bi.getColorModel();
    boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
    WritableRaster raster = bi.copyData(null);
    return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

/**
 * Creates a copy of the given image, with a solid background
 *
 * @param pOriginal   the original image
 * @param pBackground the background color
 * @return a new {@code BufferedImage}
 */
private static BufferedImage createSolid(BufferedImage pOriginal, Color pBackground) {
  // Create a temporary image of same dimension and type
  BufferedImage solid = new BufferedImage(pOriginal.getColorModel(), pOriginal.copyData(null), pOriginal.isAlphaPremultiplied(), null);
  Graphics2D g = solid.createGraphics();
  try {
    // Clear in background color
    g.setColor(pBackground);
    g.setComposite(AlphaComposite.DstOver);// Paint "underneath"
    g.fillRect(0, 0, pOriginal.getWidth(), pOriginal.getHeight());
  }
  finally {
    g.dispose();
  }
  return solid;
}

代码示例来源:origin: net.serenity-bdd/core

private BufferedImage deepCopy(BufferedImage srcImage) {
  ColorModel cm = srcImage.getColorModel();
  boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
  WritableRaster raster = srcImage.copyData(null);
  return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}

代码示例来源:origin: us.ihmc/DarpaRoboticsChallenge

private BufferedImage deepCopy(BufferedImage bi)
{
 ColorModel cm = bi.getColorModel();
 boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
 WritableRaster raster = bi.copyData(null);
 return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}

代码示例来源:origin: net.thucydides/thucydides-core

private BufferedImage deepCopy(BufferedImage srcImage) {
  ColorModel cm = srcImage.getColorModel();
  boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
  WritableRaster raster = srcImage.copyData(null);
  return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}

代码示例来源:origin: net.serenity-bdd/serenity-core

private BufferedImage deepCopy(BufferedImage srcImage) {
    ColorModel cm = srcImage.getColorModel();
    boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
    WritableRaster raster = srcImage.copyData(null);
    return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
  }
}

代码示例来源:origin: MarginallyClever/Makelangelo-software

protected BufferedImage deepCopy(BufferedImage bi) {
  ColorModel cm = bi.getColorModel();
  boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
  WritableRaster raster = bi.copyData(null);
  return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}

代码示例来源:origin: stackoverflow.com

public static BufferedImage deepCopy(BufferedImage bi) {
  ColorModel cm = bi.getColorModel();
  boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
  WritableRaster raster = bi.copyData(bi.getRaster().createCompatibleWritableRaster());
  return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}

代码示例来源:origin: stackoverflow.com

BufferedImage image = /* ... */;
BufferedImage dest = image.getSubimage(10, 20, 30, 40);  // x, y, width, height
ColorModel cm = dest.getColorModel();
BufferedImage src = new BufferedImage(cm, dest.copyData(dest.getRaster().createCompatibleWritableRaster()), cm.isAlphaPremultiplied(), null).getSubimage(0, 0, dest.getWidth(), dest.getHeight());
new ConvolveOp(new Kernel(20, 20, matrix), ConvolveOp.EDGE_NO_OP, null).filter(src, dest);

代码示例来源:origin: com.github.jjYBdx4IL/github-test-utils

public static BufferedImage deepCopy(BufferedImage bi) {
  ColorModel cm = bi.getColorModel();
  boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
  WritableRaster raster = bi.copyData(bi.getRaster().createCompatibleWritableRaster());
  return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}

代码示例来源:origin: stackoverflow.com

BufferedImage newImage = ImageIO.read(new File("test.png"));
byte newRaw[] = new byte[height*width*4];
DataBuffer newBuffer = new DataBufferByte(newRaw, newRaw.length);
WritableRaster newRaster = Raster.createWritableRaster(sampleModel, newBuffer, null);
newImage.copyData(newRaster);

代码示例来源:origin: stackoverflow.com

BufferedImage deepCopy(BufferedImage bi)/*method to clone BufferedImage*/ {
  ColorModel cm = bi.getColorModel();
  boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
  WritableRaster raster = bi.copyData(null);
  return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
BufferedImage newImg = deepCopy(oldImg);//clone it
Graphics2D g = newImg.createGraphics();
g.drawImage(newImg, 0, 0, width, height, null);//newImg will be resized

代码示例来源:origin: threerings/playn

@Override
public Image snapshot() {
 ColorModel cm = img.getColorModel();
 boolean isAlphaPremultiplied = img.isAlphaPremultiplied();
 WritableRaster raster = img.copyData(null);
 BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
 return new JavaStaticImage(ctx, snap, scale);
}

代码示例来源:origin: com.googlecode.playn/playn-java

@Override
public Image snapshot() {
 ColorModel cm = img.getColorModel();
 boolean isAlphaPremultiplied = img.isAlphaPremultiplied();
 WritableRaster raster = img.copyData(null);
 BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
 return new JavaStaticImage(ctx, snap, scale);
}

代码示例来源:origin: jtrfp/terminal-recall

private BufferedImage [] getSpecialRAWImage(String name, Color [] palette, int upscalePowerOfTwo) throws IllegalAccessException, FileLoadException, IOException{
  RAWFile dat = getRAW(name);
  dat.setPalette(palette);
  BufferedImage [] segs = dat.asSegments(upscalePowerOfTwo);
  for(BufferedImage seg:segs){
    Graphics g = seg.getGraphics();
    BufferedImage scaled = new BufferedImage(seg.getColorModel(),seg.copyData(null),seg.isAlphaPremultiplied(),null);
    g.drawImage(scaled.getScaledInstance(seg.getWidth()-2, seg.getHeight()-2, Image.SCALE_AREA_AVERAGING), 1, 1, seg.getWidth()-2, seg.getHeight()-2, null);
    g.dispose();
    }
  return segs;
  }

代码示例来源:origin: playn/playn

@Override
public Image snapshot() {
 BufferedImage bmp = ((JavaImage)image).bufferedImage();
 ColorModel cm = bmp.getColorModel();
 boolean isAlphaPremultiplied = bmp.isAlphaPremultiplied();
 WritableRaster raster = bmp.copyData(null);
 BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
 return new JavaImage(gfx, image.scale(), snap, "<canvas>");
}

代码示例来源:origin: io.playn/playn-java-base

@Override
public Image snapshot() {
 BufferedImage bmp = ((JavaImage)image).bufferedImage();
 ColorModel cm = bmp.getColorModel();
 boolean isAlphaPremultiplied = bmp.isAlphaPremultiplied();
 WritableRaster raster = bmp.copyData(null);
 BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
 return new JavaImage(gfx, image.scale(), snap, "<canvas>");
}

相关文章