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

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

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

Raster.getPixels介绍

暂无

代码示例

代码示例来源: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: org.apache.pdfbox/jbig2-imageio

@Override
protected void fetch(final int x, final int y)
{
  srcRaster.getPixels(x, y, length, 1, data);
}

代码示例来源:origin: org.apache.pdfbox/jbig2-imageio

@Override
protected void fetch(final int x, final int y)
{
  srcRaster.getPixels(x, y, length, 1, data);
  for (int i = 0; i < length; i++)
    if (data[i] != 0)
      data[i] = 255;
}

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

/**
 * Performs the transfer between the underlying raster and this window.
 */
@Override
Object getPixels(Raster raster, int subX, int subY, int subWidth, int subHeight, boolean direct) {
  return raster.getPixels(subX, subY, subWidth, subHeight, direct ? data : transfer);
}

代码示例来源:origin: com.levigo.jbig2/levigo-jbig2-imageio

@Override
protected void fetch(final int x, final int y) {
 srcRaster.getPixels(x, y, length, 1, data);
 for (int i = 0; i < length; i++)
  if (data[i] != 0)
   data[i] = 255;
}

代码示例来源:origin: org.apache.pdfbox/jbig2-imageio

@Override
protected void fetch(final int x, final int y)
{
  srcRaster.getPixels(x, y, length, 1, data);
}

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

/**
 * Performs the transfer between the underlying raster and this window.
 */
@Override
Object getPixels(Raster raster, int subX, int subY, int subWidth, int subHeight, boolean direct) {
  return raster.getPixels(subX, subY, subWidth, subHeight, direct ? data : transfer);
}

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

/**
 * Performs the transfer between the underlying raster and this window.
 */
@Override
Object getPixels(Raster raster, int subX, int subY, int subWidth, int subHeight, boolean direct) {
  return raster.getPixels(subX, subY, subWidth, subHeight, direct ? data : transfer);
}

代码示例来源:origin: com.levigo.jbig2/levigo-jbig2-imageio

@Override
protected void fetch(final int x, final int y) {
 srcRaster.getPixels(x, y, length, 1, data);
}

代码示例来源:origin: levigo/jbig2-imageio

@Override
protected void fetch(final int x, final int y) {
 srcRaster.getPixels(x, y, length, 1, data);
 for (int i = 0; i < length; i++)
  if (data[i] != 0)
   data[i] = 255;
}

代码示例来源:origin: com.levigo.jbig2/levigo-jbig2-imageio

@Override
protected void fetch(final int x, final int y) {
 srcRaster.getPixels(x, y, length, 1, data);
}

代码示例来源:origin: levigo/jbig2-imageio

@Override
protected void fetch(final int x, final int y) {
 srcRaster.getPixels(x, y, length, 1, data);
}

代码示例来源:origin: levigo/jbig2-imageio

@Override
protected void fetch(final int x, final int y) {
 srcRaster.getPixels(x, y, length, 1, data);
}

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

Raster raster = bufferedImage.getRaster();
int[] pixels = raster.getPixels(0, 0, raster.getWidth(), raster.getHeight(), (int[]) null);

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

BufferedImage img = ImageIO.read(new File(filename)); // Throws IOException
int[] pixels = img.getRGB(0,0, img.getWidth(), img.getHeight, null, 0, img.getWidth());

// also available through the BufferedImage's Raster, in multiple formats.
Raster r = img.getData();
int[] pixels = r.getPixels(0,0,r.getWidth(), r.getHeight(), (int[])null);

代码示例来源:origin: com.jhlabs/filters

public void compose( Raster src, Raster dstIn, WritableRaster dstOut ) {
  float alpha = this.alpha;
  int[] srcPix = null;
  int[] dstPix = null;
  int x = dstOut.getMinX();
  int w = dstOut.getWidth();
  int y0 = dstOut.getMinY();
  int y1 = y0 + dstOut.getHeight();
  for ( int y = y0; y < y1; y++ ) {
    srcPix = src.getPixels( x, y, w, 1, srcPix );
    dstPix = dstIn.getPixels( x, y, w, 1, dstPix );
    composeRGB( srcPix, dstPix, alpha );
    dstOut.setPixels( x, y, w, 1, dstPix );
  }
}

代码示例来源:origin: eu.mihosoft.vrl/vrl

public void compose( Raster src, Raster dstIn, WritableRaster dstOut ) {
  float alpha = this.alpha;
  int[] srcPix = null;
  int[] dstPix = null;
  int x = dstOut.getMinX();
  int w = dstOut.getWidth();
  int y0 = dstOut.getMinY();
  int y1 = y0 + dstOut.getHeight();
  for ( int y = y0; y < y1; y++ ) {
    srcPix = src.getPixels( x, y, w, 1, srcPix );
    dstPix = dstIn.getPixels( x, y, w, 1, dstPix );
    composeRGB( srcPix, dstPix, alpha );
    dstOut.setPixels( x, y, w, 1, dstPix );
  }
}

代码示例来源:origin: cn.apiclub.tool/simplecaptcha

public void compose( Raster src, Raster dstIn, WritableRaster dstOut ) {
  float alpha = this.alpha;
  int[] srcPix = null;
  int[] dstPix = null;
  int x = dstOut.getMinX();
  int w = dstOut.getWidth();
  int y0 = dstOut.getMinY();
  int y1 = y0 + dstOut.getHeight();
  for ( int y = y0; y < y1; y++ ) {
    srcPix = src.getPixels( x, y, w, 1, srcPix );
    dstPix = dstIn.getPixels( x, y, w, 1, dstPix );
    composeRGB( srcPix, dstPix, alpha );
    dstOut.setPixels( x, y, w, 1, dstPix );
  }
}

代码示例来源:origin: it.geosolutions.jaiext.colorconvert/jt-colorconvert

private Raster convertRasterToUnsigned(Raster ras) {
  int type = ras.getSampleModel().getDataType();
  WritableRaster tempRas = null;
  if ((type == DataBuffer.TYPE_INT || type == DataBuffer.TYPE_SHORT)) {
    int minX = ras.getMinX(), minY = ras.getMinY();
    int w = ras.getWidth(), h = ras.getHeight();
    int[] buf = ras.getPixels(minX, minY, w, h, (int[]) null);
    convertBufferToUnsigned(buf, type);
    tempRas = createTempWritableRaster(ras);
    tempRas.setPixels(minX, minY, w, h, buf);
    return tempRas;
  }
  return ras;
}

代码示例来源:origin: geosolutions-it/jai-ext

private Raster convertRasterToUnsigned(Raster ras) {
  int type = ras.getSampleModel().getDataType();
  WritableRaster tempRas = null;
  if ((type == DataBuffer.TYPE_INT || type == DataBuffer.TYPE_SHORT)) {
    int minX = ras.getMinX(), minY = ras.getMinY();
    int w = ras.getWidth(), h = ras.getHeight();
    int[] buf = ras.getPixels(minX, minY, w, h, (int[]) null);
    convertBufferToUnsigned(buf, type);
    tempRas = createTempWritableRaster(ras);
    tempRas.setPixels(minX, minY, w, h, buf);
    return tempRas;
  }
  return ras;
}

相关文章