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

x33g5p2x  于2022-01-28 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(159)

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

Raster.createCompatibleWritableRaster介绍

暂无

代码示例

代码示例来源:origin: org.apache.poi/poi

public void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform)
{
  BufferedImage bufferedimage = new BufferedImage(renderedimage.getColorModel(), renderedimage.getData().createCompatibleWritableRaster(), false, null);
  bufferedimage.setData(renderedimage.getData());
  drawImage(bufferedimage, affinetransform, null);
}

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

public WritableRaster createCompatibleDestRaster(Raster src) {
  return src.createCompatibleWritableRaster();
}

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

public WritableRaster createCompatibleDestRaster(Raster src) {
  return src.createCompatibleWritableRaster(width, height);
}

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

public WritableRaster createCompatibleDestRaster(final Raster src) {
    // WHAT?? This code no longer work for JRE 7u45+... JRE bug?!
//        Raster child = src.createChild(0, 0, src.getWidth(), src.getHeight(), 0, 0, new int[] {0, 1, 2});
//        return child.createCompatibleWritableRaster(); // Throws an exception complaining about the scanline stride from the verify() method

    // This is a workaround for the above code that no longer works.
    // It wil use 25% more memory, but it seems to work...
    WritableRaster raster = src.createCompatibleWritableRaster();
    return raster.createWritableChild(0, 0, src.getWidth(), src.getHeight(), 0, 0, new int[] {0, 1, 2});
  }

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

/** Sets raster and sampleModel */
private void allocateRaster(boolean inverted) {
  final int value = inverted ? 1 : 0;
  WritableRaster result;
  if ((tileWidth != tileHeight) || (value == 0)) {
    result = buildSolidRaster(tileWidth, tileHeight, value);
  } else {
    Raster template = getSolidRaster(tileWidth, tileHeight, value);
    result = template.createCompatibleWritableRaster();
    byte[] src = ((DataBufferByte) template.getDataBuffer()).getData();
    byte[] dst = ((DataBufferByte) result.getDataBuffer()).getData();
    System.arraycopy(src, 0, dst, 0, src.length);
  }
  raster = result;
}

代码示例来源:origin: apache/pdfbox

private WritableRaster fromBGRtoRGB(Raster raster)
{
  WritableRaster writableRaster = raster.createCompatibleWritableRaster();
  int width = raster.getWidth();
  int height = raster.getHeight();
  int w3 = width * 3;
  int[] tab = new int[w3];
  //BEWARE: handling the full image at a time is slower than one line at a time        
  for (int y = 0; y < height; y++)
  {
    raster.getPixels(0, y, width, 1, tab);
    for (int off = 0; off < w3; off += 3)
    {
      int tmp = tab[off];
      tab[off] = tab[off + 2];
      tab[off + 2] = tmp;
    }
    writableRaster.setPixels(0, y, width, 1, tab);
  }
  return writableRaster;
}

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

/**
 * Gets pixel data of an <code>RenderedImage</code> object.
 *
 * @param image an <code>RenderedImage</code> object
 * @return a byte buffer of pixel data
 */
public static ByteBuffer getImageByteBuffer(RenderedImage image) {
  ColorModel cm = image.getColorModel();
  WritableRaster wr = image.getData().createCompatibleWritableRaster(image.getWidth(), image.getHeight());
  image.copyData(wr);
  BufferedImage bi = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
  return convertImageData(bi);
}

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

WritableRaster dest = src.createCompatibleWritableRaster();

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

raster = data.createCompatibleWritableRaster();
raster = pOriginal.copyData(raster);

代码示例来源:origin: apache/pdfbox

private WritableRaster fromYCCKtoCMYK(Raster raster)
  WritableRaster writableRaster = raster.createCompatibleWritableRaster();

代码示例来源:origin: apache/pdfbox

private WritableRaster fromYCbCrtoCMYK(Raster raster)
  WritableRaster writableRaster = raster.createCompatibleWritableRaster();

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

final WritableRaster rowRaster = shift != 0 ? tile.createCompatibleWritableRaster(tile.getWidth(), 1) : null;
final DataBuffer rowBuffer = shift != 0 ? rowRaster.getDataBuffer() : null;

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

Raster raster = ...; // Your raster
ColorModel colorModel = ...; // A suitable color model (see comment section)

WritableRaster writableRaster = raster.createCompatibleWritableRaster();
writableRaster.setDataElements(0, 0, raster);
BufferedImage image = new BufferedImage(colorModel, writableRaster, colorModel.isAlphaPremultiplied(), null);

代码示例来源:origin: com.twelvemonkeys.imageio/imageio-jpeg

public WritableRaster createCompatibleDestRaster(final Raster src) {
    // WHAT?? This code no longer work for JRE 7u45+... JRE bug?!
//        Raster child = src.createChild(0, 0, src.getWidth(), src.getHeight(), 0, 0, new int[] {0, 1, 2});
//        return child.createCompatibleWritableRaster(); // Throws an exception complaining about the scanline stride from the verify() method

    // This is a workaround for the above code that no longer works.
    // It wil use 25% more memory, but it seems to work...
    WritableRaster raster = src.createCompatibleWritableRaster();
    return raster.createWritableChild(0, 0, src.getWidth(), src.getHeight(), 0, 0, new int[] {0, 1, 2});
  }

代码示例来源:origin: org.apache.xmlgraphics/batik-awt-util

public WritableRaster createCompatibleDestRaster(Raster src){
  checkCompatible(src.getSampleModel());
  // Src Raster is OK: create a similar Raster for destination.
  return src.createCompatibleWritableRaster();
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

public WritableRaster createCompatibleDestRaster(Raster src){
  checkCompatible(src.getSampleModel());
  // Src Raster is OK: create a similar Raster for destination.
  return src.createCompatibleWritableRaster();
}

代码示例来源:origin: com.haulmont.thirdparty/poi

public void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform)
{
  BufferedImage bufferedimage = new BufferedImage(renderedimage.getColorModel(), renderedimage.getData().createCompatibleWritableRaster(), false, null);
  bufferedimage.setData(renderedimage.getData());
  drawImage(bufferedimage, affinetransform, null);
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

public void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform)
{
  BufferedImage bufferedimage = new BufferedImage(renderedimage.getColorModel(), renderedimage.getData().createCompatibleWritableRaster(), false, null);
  bufferedimage.setData(renderedimage.getData());
  drawImage(bufferedimage, affinetransform, null);
}

代码示例来源:origin: org.openmicroscopy/ome-poi

public void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform)
{
  BufferedImage bufferedimage = new BufferedImage(renderedimage.getColorModel(), renderedimage.getData().createCompatibleWritableRaster(), false, null);
  bufferedimage.setData(renderedimage.getData());
  drawImage(bufferedimage, affinetransform, null);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

public void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform)
{
  BufferedImage bufferedimage = new BufferedImage(renderedimage.getColorModel(), renderedimage.getData().createCompatibleWritableRaster(), false, null);
  bufferedimage.setData(renderedimage.getData());
  drawImage(bufferedimage, affinetransform, null);
}

相关文章