/** * Returns the {@code String} representation of the contents of this {@code ColorModel}object. * * @return a {@code String} representing the contents of this {@code ColorModel} object. */ public String toString() { return new String( "ComponentColorModelJAI: #pixelBits = " + pixel_bits + " numComponents = " + super.getNumComponents() + " color space = " + super.getColorSpace() + " transparency = " + super.getTransparency() + " has alpha = " + super.hasAlpha() + " isAlphaPre = " + super.isAlphaPremultiplied()); } }
buffer, pBitmap.getWidth(), pBitmap.getHeight(), scanlineStride, 3, bOffs, null ); pBitmap.image = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null);
int w = 1024, h = 1024; // or whatever you prefer ColorSpace xyzCS = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ); ComponentColorModel cm = new ComponentColorModel(xyzCS, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster raster = cm.createCompatibleWritableRaster(w, h); BufferedImage xyzImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null);
@Override protected BufferedImage createImage(int width, int height) { ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY); ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); WritableRaster raster = ccm.createCompatibleWritableRaster(width, height); return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null); } }
@Override protected BufferedImage createImage(int width, int height) { ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY); ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); WritableRaster raster = ccm.createCompatibleWritableRaster(width, height); return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null); } }
@Override protected BufferedImage createImage(int width, int height) { ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY); ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); WritableRaster raster = ccm.createCompatibleWritableRaster(width, height); return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null); } }
@Override public Graphics2D prepare(Component component, Graphics2D graphicsArgument) { this.graphics = graphicsArgument; int width = component.getWidth(); int height = component.getHeight(); /* To convert to gray, we create a BufferedImage in the grayscale color * space into which the decorated component draws, and we output the * resulting image. The naive way to create the buffer is new * BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); but that * doesn't respect transparency. Hence the following more complicated * method. */ if (bufferedImage == null || bufferedImage.getWidth() < width || bufferedImage.getHeight() < height) { ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY); ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); WritableRaster raster = ccm.createCompatibleWritableRaster(width, height); bufferedImage = new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null); } bufferedImageGraphics = bufferedImage.createGraphics(); bufferedImageGraphics.setClip(graphicsArgument.getClip()); return bufferedImageGraphics; }
@Override public Graphics2D prepare(Component component, Graphics2D graphics) { this.graphics = graphics; int width = component.getWidth(); int height = component.getHeight(); /* To convert to gray, we create a BufferedImage in the grayscale color * space into which the decorated component draws, and we output the * resulting image. The naive way to create the buffer is new * BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); but that * doesn't respect transparency. Hence the following more complicated * method. */ if (bufferedImage == null || bufferedImage.getWidth() < width || bufferedImage.getHeight() < height) { ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY); ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); WritableRaster raster = ccm.createCompatibleWritableRaster(width, height); bufferedImage = new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null); } bufferedImageGraphics = bufferedImage.createGraphics(); bufferedImageGraphics.setClip(graphics.getClip()); return bufferedImageGraphics; }
/** * Returns the {@code String} representation of the contents of * this {@code ColorModel}object. * * @return a {@code String} representing the contents of this * {@code ColorModel} object. */ public String toString() { return new String("ComponentColorModelJAI: #pixelBits = "+pixel_bits + " numComponents = "+ super.getNumComponents() + " color space = "+ super.getColorSpace() + " transparency = "+ super.getTransparency() + " has alpha = "+ super.hasAlpha() + " isAlphaPre = "+ super.isAlphaPremultiplied()); } }
/** * Returns the {@code String} representation of the contents of * this {@code ColorModel}object. * * @return a {@code String} representing the contents of this * {@code ColorModel} object. */ public String toString() { return new String("ComponentColorModelJAI: #pixelBits = "+pixel_bits + " numComponents = "+ super.getNumComponents() + " color space = "+ super.getColorSpace() + " transparency = "+ super.getTransparency() + " has alpha = "+ super.hasAlpha() + " isAlphaPre = "+ super.isAlphaPremultiplied()); } }
(imgCompCM, wr, imgCompCM.isAlphaPremultiplied(), null); new int[]{0, 0, 0}, new Point(0, 0)); BufferedImage newImg = new BufferedImage (newCM, srcWR, newCM.isAlphaPremultiplied(), null);
(imgCompCM, wr, imgCompCM.isAlphaPremultiplied(), null); new int[]{0, 0, 0}, new Point(0, 0)); BufferedImage newImg = new BufferedImage (newCM, srcWR, newCM.isAlphaPremultiplied(), null);
(imgCompCM, wr, imgCompCM.isAlphaPremultiplied(), null); new int[]{0, 0, 0}, new Point(0, 0)); BufferedImage newImg = new BufferedImage (newCM, srcWR, newCM.isAlphaPremultiplied(), null);
private void readBitmap24(final BitmapDescriptor pBitmap) throws IOException { byte[] pixels = new byte[pBitmap.getWidth() * pBitmap.getHeight() * 3]; // Create TYPE_3BYTE_BGR DataBuffer buffer = new DataBufferByte(pixels, pixels.length); ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); int[] nBits = {8, 8, 8}; int[] bOffs = {2, 1, 0}; ComponentColorModel cm = new ComponentColorModel( cs, nBits, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE ); WritableRaster raster = Raster.createInterleavedRaster( buffer, pBitmap.getWidth(), pBitmap.getHeight(), pBitmap.getWidth(), 3, bOffs, null ); pBitmap.image = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); for (int y = 0; y < pBitmap.getHeight(); y++) { int offset = (pBitmap.getHeight() - y - 1) * pBitmap.getWidth(); imageInput.readFully(pixels, offset, pBitmap.getWidth() * 3); // TODO: Possibly read padding byte here! if (abortRequested()) { processReadAborted(); break; } processImageProgress(100 * y / (float) pBitmap.getHeight()); } }
buffer, pBitmap.getWidth(), pBitmap.getHeight(), scanlineStride, 3, bOffs, null ); pBitmap.image = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null);
else return new ComponentColorModel(cs, ccm.hasAlpha(), ccm .isAlphaPremultiplied(), ccm.getTransparency(), ccm .getTransferType()); } else if (old_cm instanceof DirectColorModel) {
ccm.isAlphaPremultiplied(), ccm.getTransparency(), ccm.getTransferType()); } else if (colorModel instanceof DirectColorModel) {