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 ); } }
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 ); } }
/** * 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; }
@Override public void readRow(int y) { raster.getDataElements(0, y, raster.getWidth(), 1, pixels); }
@Override public void readRow(int y) { raster.getDataElements(0, y, raster.getWidth(), 1, pixels); }
@Override public void readRow(int y) { raster.getDataElements(0, y, raster.getWidth(), 1, pixels); }
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); } } };
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); } } };
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); } } };
pixelInput = raster.getDataElements(x, y, pixelInput);
for (int x = 0; x < raster.getWidth(); x += xIncrement) { data = raster.getDataElements(x, y, data);
imageRaster.getDataElements(0, rowNum, width, 1, transferRow);
srcPixel = src.getDataElements(x, y, srcPixel); dstPixel = dstIn.getDataElements(dstInXShift + x, dstInYShift + y, dstPixel);
dataElements = sourceRow.getDataElements(srcX, 0, dataElements); int dstX = srcX / sourceXSubsampling; destination.setDataElements(dstX, dstY, dataElements);
/** * 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; }
/** * 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; } }
srcTile.getDataElements( srcTile.getMinX(), srcTile.getMinY(),
srcTile.getDataElements( srcTile.getMinX(), srcTile.getMinY(),
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);
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];