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

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

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

Raster.getDataElements介绍

暂无

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

private void drawImage( SwingUniversalImage image, int centerX, int centerY, double angle, int imageSize ) {
 if ( isDrawingPixelatedImages() && image.isBitmap() ) {
  BufferedImage img =  image.getAsBitmapForSize( imageSize, imageSize, angle );
  ColorModel cm = img.getColorModel();
  Raster raster = img.getRaster();
  int offx = centerX + xOffset - img.getWidth() / 2;
  int offy = centerY + yOffset - img.getHeight() / 2;
  for ( int x = 0; x < img.getWidth( observer ); x++ ) {
   for ( int y = 0; y < img.getHeight( observer ); y++ ) {
    Object pix = raster.getDataElements( x, y, null );
    gc.setColor( new Color( cm.getRed( pix ), cm.getGreen( pix ), cm.getBlue( pix ), cm.getAlpha( pix ) ) );
    gc.setStroke( new BasicStroke( 1.0f ) );
    gc.drawLine(
      offx + x,
      offy + y,
      offx + x + 1,
      offy + y + 1 );
   }
  }
 } else {
  image.drawToGraphics( gc, centerX, centerY, imageSize, imageSize, angle );
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

private void drawImage( SwingUniversalImage image, int locationX, int locationY, int imageSize ) {
 if ( isDrawingPixelatedImages() && image.isBitmap() ) {
  BufferedImage img = image.getAsBitmapForSize( imageSize, imageSize );
  ColorModel cm = img.getColorModel();
  Raster raster = img.getRaster();
  for ( int x = 0; x < img.getWidth( observer ); x++ ) {
   for ( int y = 0; y < img.getHeight( observer ); y++ ) {
    Object pix = raster.getDataElements( x, y, null );
    gc.setColor( new Color( cm.getRed( pix ), cm.getGreen( pix ), cm.getBlue( pix ), cm.getAlpha( pix ) ) );
    gc.setStroke( new BasicStroke( 1.0f ) );
    gc.drawLine(
      locationX + xOffset + x,
      locationY + yOffset + y,
      locationX + xOffset + x + 1,
      locationY + yOffset + y + 1 );
   }
  }
 } else {
  image.drawToGraphics( gc, locationX, locationY, imageSize, imageSize );
 }
}

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

/**
 * Gets a specific pixel color from the specified buffered image
 *
 * @param image
 * @param i
 * @param j
 * @param color
 */
protected Color getPixelColor(BufferedImage image, int i, int j) {
  ColorModel cm = image.getColorModel();
  Raster raster = image.getRaster();
  Object pixel = raster.getDataElements(i, j, null);
  Color actual;
  if (cm.hasAlpha()) {
    actual =
        new Color(
            cm.getRed(pixel),
            cm.getGreen(pixel),
            cm.getBlue(pixel),
            cm.getAlpha(pixel));
  } else {
    actual = new Color(cm.getRed(pixel), cm.getGreen(pixel), cm.getBlue(pixel), 255);
  }
  return actual;
}

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

@Override
public void readRow(int y) {
  raster.getDataElements(0, y, raster.getWidth(), 1, pixels);
}

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

@Override
public void readRow(int y) {
  raster.getDataElements(0, y, raster.getWidth(), 1, pixels);
}

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

@Override
public void readRow(int y) {
  raster.getDataElements(0, y, raster.getWidth(), 1, pixels);
}

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

public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
    int width = min(src.getWidth(), dstIn.getWidth());
    // We always work in RGB, using DataBuffer.TYPE_INT transfer type.
    int[] srcData = null;
    int[] dstData = null;
    int[] resData = new int[width - src.getMinX()];
    for (int y = src.getMinY(); y < src.getHeight(); y++) {
      srcData = (int[]) src.getDataElements(src.getMinX(), y, width, 1, srcData);
      dstData = (int[]) dstIn.getDataElements(src.getMinX(), y, width, 1, dstData);
      for (int x = src.getMinX(); x < width; x++) {
        // TODO: Decide how to handle alpha (if at all)
        resData[x] = 0xff000000 | ((~srcData[x] ^ dstData[x])) & 0xffffff;
      }
      dstOut.setDataElements(src.getMinX(), y, width, 1, resData);
    }
  }
};

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

public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
    int width = min(src.getWidth(), dstIn.getWidth());
    // We always work in RGB, using DataBuffer.TYPE_INT transfer type.
    int[] srcData = null;
    int[] dstData = null;
    int[] resData = new int[width - src.getMinX()];
    for (int y = src.getMinY(); y < src.getHeight(); y++) {
      srcData = (int[]) src.getDataElements(src.getMinX(), y, width, 1, srcData);
      dstData = (int[]) dstIn.getDataElements(src.getMinX(), y, width, 1, dstData);
      for (int x = src.getMinX(); x < width; x++) {
        int sAlpha = (srcData[x] >>> 24) & 0xFF;
        int sRed = sAlpha * ((srcData[x] >> 16) & 0xFF) / 0xFF;
        int sGreen = sAlpha * ((srcData[x] >> 8) & 0xFF) / 0xFF;
        int sBlue = sAlpha * ((srcData[x]) & 0xFF) / 0xFF;
        int dAlpha = (dstData[x] >>> 24) & 0xFF;
        int dRed = dAlpha * ((dstData[x] >> 16) & 0xFF) / 0xFF;
        int dGreen = dAlpha * ((dstData[x] >> 8) & 0xFF) / 0xFF;
        int dBlue = dAlpha * ((dstData[x]) & 0xFF) / 0xFF;
        resData[x] = (max(sAlpha, dAlpha) << 24)
               | (max(sRed, dRed) << 16)
               | (max(sGreen, dGreen) << 8)
               | (max(sBlue, dBlue));
      }
      dstOut.setDataElements(src.getMinX(), y, width, 1, resData);
    }
  }
};

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

public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
    int width = min(src.getWidth(), dstIn.getWidth());
    // We always work in RGB, using DataBuffer.TYPE_INT transfer type.
    int[] srcData = null;
    int[] dstData = null;
    int[] resData = new int[width - src.getMinX()];
    for (int y = src.getMinY(); y < src.getHeight(); y++) {
      srcData = (int[]) src.getDataElements(src.getMinX(), y, width, 1, srcData);
      dstData = (int[]) dstIn.getDataElements(src.getMinX(), y, width, 1, dstData);
      for (int x = src.getMinX(); x < width; x++) {
        int sAlpha = (srcData[x] >>> 24) & 0xFF;
        int sRed = sAlpha * ((srcData[x] >> 16) & 0xFF) / 0xFF;
        int sGreen = sAlpha * ((srcData[x] >> 8) & 0xFF) / 0xFF;
        int sBlue = sAlpha * ((srcData[x]) & 0xFF) / 0xFF;
        int dAlpha = (dstData[x] >>> 24) & 0xFF;
        int dRed = dAlpha * ((dstData[x] >> 16) & 0xFF) / 0xFF;
        int dGreen = dAlpha * ((dstData[x] >> 8) & 0xFF) / 0xFF;
        int dBlue = dAlpha * ((dstData[x]) & 0xFF) / 0xFF;
        resData[x] = (min(sAlpha, dAlpha) << 24)
               | (min(sRed, dRed) << 16)
               | (min(sGreen, dGreen) << 8)
               | (min(sBlue, dBlue));
      }
      dstOut.setDataElements(src.getMinX(), y, width, 1, resData);
    }
  }
};

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

pixelInput = raster.getDataElements(x, y, pixelInput);

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

for (int x = 0; x < raster.getWidth(); x += xIncrement) {
  data = raster.getDataElements(x, y, data);

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

imageRaster.getDataElements(0, rowNum, width, 1, transferRow);

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

srcPixel = src.getDataElements(x, y, srcPixel);
dstPixel = dstIn.getDataElements(dstInXShift + x, dstInYShift + y, dstPixel);

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

dataElements = sourceRow.getDataElements(srcX, 0, dataElements);
int dstX = srcX / sourceXSubsampling;
destination.setDataElements(dstX, dstY, dataElements);

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

/**
 * Gets a specific pixel color from the specified buffered image
 *
 * @param image
 * @param i
 * @param j
 * @param color
 * @return
 */
private static Color getPixelColor(BufferedImage image, int i, int j) {
  ColorModel cm = image.getColorModel();
  Raster raster = image.getRaster();
  Object pixel = raster.getDataElements(i, j, null);
  Color actual;
  if (cm.hasAlpha()) {
    actual =
        new Color(
            cm.getRed(pixel),
            cm.getGreen(pixel),
            cm.getBlue(pixel),
            cm.getAlpha(pixel));
  } else {
    actual = new Color(cm.getRed(pixel), cm.getGreen(pixel), cm.getBlue(pixel), 255);
  }
  return actual;
}

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

/**
   * Gets a specific pixel color from the specified buffered image
   *
   * @param image
   * @param i
   * @param j
   * @param color
   * @return
   */
  protected Color getPixelColor(BufferedImage image, int i, int j) {
    ColorModel cm = image.getColorModel();
    Raster raster = image.getRaster();
    Object pixel = raster.getDataElements(i, j, null);

    Color actual;
    if (cm.hasAlpha()) {
      actual =
          new Color(
              cm.getRed(pixel),
              cm.getGreen(pixel),
              cm.getBlue(pixel),
              cm.getAlpha(pixel));
    } else {
      actual = new Color(cm.getRed(pixel), cm.getGreen(pixel), cm.getBlue(pixel), 255);
    }
    return actual;
  }
}

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

srcTile.getDataElements(
    srcTile.getMinX(),
    srcTile.getMinY(),

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

srcTile.getDataElements(
    srcTile.getMinX(),
    srcTile.getMinY(),

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

dataElements = sourceRow.getDataElements(srcX, 0, dataElements);
int dstX = /*offset.x +*/ srcX / sourceXSubsampling;
destination.setDataElements(dstX, dstY, dataElements);
dataElements = sourceRow.getDataElements(srcX, 0, dataElements);
int rgb = icm.getRGB(dataElements);
outDataElements = image.getColorModel().getDataElements(rgb, outDataElements);

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

src.getDataElements(x, y, in);
convertCMYKToRGB(in, out);
dest.setDataElements(x, y, out);
src.getDataElements(x, y, in);
convertCMYKToRGB(in, temp);
out[0] = alpha << 24 | (temp[0] & 0xFF) << bitOffsets[0] | (temp[1] & 0xFF) << bitOffsets[1] | (temp[2] & 0xFF) << bitOffsets[2];

相关文章