private int getPhotometricInterpretation(final ColorModel colorModel, int compression) { if (colorModel.getPixelSize() == 1) { if (colorModel instanceof IndexColorModel) { if (colorModel.getRGB(0) == 0xFFFFFFFF && colorModel.getRGB(1) == 0xFF000000) { return TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO; } else if (colorModel.getRGB(0) != 0xFF000000 || colorModel.getRGB(1) != 0xFFFFFFFF) { return TIFFBaseline.PHOTOMETRIC_PALETTE; } // Else, fall through to default, BLACK_IS_ZERO } return TIFFBaseline.PHOTOMETRIC_BLACK_IS_ZERO; } else if (colorModel instanceof IndexColorModel) { return TIFFBaseline.PHOTOMETRIC_PALETTE; } switch (colorModel.getColorSpace().getType()) { case ColorSpace.TYPE_GRAY: return TIFFBaseline.PHOTOMETRIC_BLACK_IS_ZERO; case ColorSpace.TYPE_RGB: return compression == TIFFExtension.COMPRESSION_JPEG ? TIFFExtension.PHOTOMETRIC_YCBCR : TIFFBaseline.PHOTOMETRIC_RGB; case ColorSpace.TYPE_CMYK: return TIFFExtension.PHOTOMETRIC_SEPARATED; } throw new IllegalArgumentException("Can't determine PhotometricInterpretation for color model: " + colorModel); }
private void multiPaletteToRGB(final int row, final byte[] indexed, final IndexColorModel colorModel, final byte[] dest, final int destOffset) { final int width = header.width; ColorModel palette = paletteChange.getColorModel(colorModel, row, isLaced()); for (int x = 0; x < width; x++) { int pixel = indexed[x] & 0xff; int rgb = palette.getRGB(pixel); int offset = (x * 3) + destOffset; dest[2 + offset] = (byte) ((rgb >> 16) & 0xff); dest[1 + offset] = (byte) ((rgb >> 8) & 0xff); dest[ offset] = (byte) ( rgb & 0xff); } }
int rgb = model.getRGB(pixels[off + i * scansize + j]);
int rgb = model.getRGB(pixels[off + i * scansize + j] & 0xFF);
public static int makeRGB(int v, ColorModel cm) { // TODO: Consider inclusion of alpha if (cm == null) return (255<<24) + (v<<16) + (v<<8) + v; else return cm.getRGB(v); }
private Color getSrcColor(int x, int y) { int argb = srcColorModel.getRGB(srcRaster.getDataElements(x, y, null)); return new Color(argb, transparency != Transparency.OPAQUE); }
private Color getSrcColor(int x, int y) { int argb = srcColorModel.getRGB(srcRaster.getDataElements(x, y, null)); return new Color(argb, transparency != Transparency.OPAQUE); }
private Color getSrcColor(int x, int y) { int argb = srcColorModel.getRGB(srcRaster.getDataElements(x, y, null)); return new Color(argb, transparency != Transparency.OPAQUE); }
private Color getSrcColor(int x, int y) { int argb = srcColorModel.getRGB(srcRaster.getDataElements(x, y, null)); return new Color(argb, transparency != Transparency.OPAQUE); }
private int getRGB(float value) { return cm.getRGB(getColorIndex(value) & 0xff); }
private int getRGB(int value) { return cm.getRGB(getColorIndex(value) & 0xff); }
private int getRGB(double value) { return cm.getRGB(getColorIndex(value) & 0xff); }
private void multiPaletteToRGB(final int row, final byte[] indexed, final IndexColorModel colorModel, final byte[] dest, final int destOffset) { final int width = header.width; ColorModel palette = paletteChange.getColorModel(colorModel, row, isLaced()); for (int x = 0; x < width; x++) { int pixel = indexed[x] & 0xff; int rgb = palette.getRGB(pixel); int offset = (x * 3) + destOffset; dest[2 + offset] = (byte) ((rgb >> 16) & 0xff); dest[1 + offset] = (byte) ((rgb >> 8) & 0xff); dest[ offset] = (byte) ( rgb & 0xff); } }
/** * Returns the color at the specified row and column. */ public Color getColorAt(int y, int x) { final Raster raster = getRasterAt(y+=minY, x+=minX); if (raster == null) { return null; } pixel = raster.getDataElements(x, y, pixel); return new Color(image.getColorModel().getRGB(pixel), true); }
public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize) { int[] rgbPixels = new int[w]; for (int row = 0; row < h; ++row) { int rowOff = off + row * scansize; for (int col = 0; col < w; ++col) rgbPixels[col] = model.getRGB(pixels[rowOff + col] & 0xff); try { encodePixelsWrapper(x, y + row, w, 1, rgbPixels, 0, w); } catch (IOException e) { iox = e; stop(); return; } } }
public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize) { int[] rgbPixels = new int[w]; for (int row = 0; row < h; ++row) { int rowOff = off + row * scansize; for (int col = 0; col < w; ++col) rgbPixels[col] = model.getRGB(pixels[rowOff + col] & 0xff); try { encodePixelsWrapper(x, y + row, w, 1, rgbPixels, 0, w); } catch (IOException e) { iox = e; stop(); return; } } }
@Override public void colorUpdated(Color3f newColor) { if (newColor == null) { final int val = c.getImage().getProcessor().getColorModel().getRGB(c.getThreshold()); newColor = new Color3f(new Color(val)); } mesh.setColor(newColor); }
public void computeRect(Raster[] sources, WritableRaster dest, Rectangle destRect) { LOGGER.debug("Start computing region: " + destRect); ColorModel srcCM = getSourceImage(0).getColorModel(); ColorModel destCM = getColorModel(); Object srcData = null; Object destData = null; for (int i = destRect.x + destRect.width; --i >= destRect.x;) { for (int j = destRect.y + destRect.height; --j >= destRect.y;) { srcData = sources[0].getDataElements(i, j, srcData); destData = destCM.getDataElements(srcCM.getRGB(srcData), destData); dest.setDataElements(i, j, destData); } } LOGGER.debug("Region computed: " + destRect); }
public RBGColorTransformInfo(ColorTransformer.ColorTransformMethod method) { super(8); this.method = method; setMinMaxAllowed(0, ColorTransformer.getDefaultTransformedMax(method)); setMinDisplay(0); setMaxDisplay(getMaxAllowed()); colorModel = ColorTransformerAWT.getDefaultColorModel(method); if (colorModel != null) color = colorModel.getRGB(255); }
public MeshGroup(final ContentInstant c) { super(); this.c = c; Color3f color = c.getColor(); final List tri = triangulator.getTriangles(c.getImage(), c.getThreshold(), c.getChannels(), c.getResamplingFactor()); if (color == null) { final int value = c.getImage().getProcessor().getColorModel().getRGB(c.getThreshold()); color = new Color3f(new Color(value)); } mesh = new CustomTriangleMesh(tri, color, c.getTransparency()); calculateMinMaxCenterPoint(); addChild(mesh); }