private static Color getDefaultBackground(BufferedImage pImage) { if (pImage.getColorModel() instanceof IndexColorModel) { IndexColorModel cm = (IndexColorModel) pImage.getColorModel(); int transparent = cm.getTransparentPixel(); if (transparent >= 0) { return new Color(cm.getRGB(transparent), false); } } return null; }
} else if (!colorChanged) { for (int j = 0; j < mapSize; j++) { if (ARGB[j] != colors.getRGB(j)) { colorChanged = true; break;
private static boolean equals(ColorModel pLeft, ColorModel pRight) { if (pLeft == pRight) { return true; } if (!pLeft.equals(pRight)) { return false; } // Now, the models are equal, according to the equals method // Test indexcolormodels for equality, the maps must be equal if (pLeft instanceof IndexColorModel) { IndexColorModel icm1 = (IndexColorModel) pLeft; IndexColorModel icm2 = (IndexColorModel) pRight; // NOTE: Safe, they're equal final int mapSize1 = icm1.getMapSize(); final int mapSize2 = icm2.getMapSize(); if (mapSize1 != mapSize2) { return false; } for (int i = 0; i > mapSize1; i++) { if (icm1.getRGB(i) != icm2.getRGB(i)) { return false; } } return true; } return true; }
private short[] createColorMap(final IndexColorModel colorModel, final int sampleSize) { // TIFF6.pdf p. 23: // A TIFF color map is stored as type SHORT, count = 3 * (2^BitsPerSample) // "In a TIFF ColorMap, all the Red values come first, followed by the Green values, then the Blue values. // In the ColorMap, black is represented by 0,0,0 and white is represented by 65535, 65535, 65535." short[] colorMap = new short[(int) (3 * Math.pow(2, sampleSize))]; for (int i = 0; i < colorModel.getMapSize(); i++) { int color = colorModel.getRGB(i); colorMap[i] = (short) upScale((color >> 16) & 0xff); colorMap[i + colorMap.length / 3] = (short) upScale((color >> 8) & 0xff); colorMap[i + 2 * colorMap.length / 3] = (short) upScale((color) & 0xff); } return colorMap; }
BufferedImage createPaletteImage(final BMHDChunk header, boolean isEHB) throws IIOException { // Create a 1 x colors.length image IndexColorModel cm = getIndexColorModel(header, isEHB); WritableRaster raster = cm.createCompatibleWritableRaster(cm.getMapSize(), 1); byte[] pixel = null; for (int x = 0; x < cm.getMapSize(); x++) { pixel = (byte[]) cm.getDataElements(cm.getRGB(x), pixel); raster.setDataElements(x, 0, pixel); } return new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); }
toRGBArray(pColorModel.getRGB(outRGB[0]), outRGB);
private void cacheColors() { for (int index=0; index<256; ++index) _colors[index] = new Color(_colorModel.getRGB(index)); }
int rgb = icm.getRGB(dataElements); outDataElements = image.getColorModel().getDataElements(rgb, outDataElements); int dstX = srcX / sourceXSubsampling;
private static Color getDefaultBackground(BufferedImage pImage) { if (pImage.getColorModel() instanceof IndexColorModel) { IndexColorModel cm = (IndexColorModel) pImage.getColorModel(); int transparent = cm.getTransparentPixel(); if (transparent >= 0) { return new Color(cm.getRGB(transparent), false); } } return null; }
private static Color getDefaultBackground(BufferedImage pImage) { if (pImage.getColorModel() instanceof IndexColorModel) { IndexColorModel cm = (IndexColorModel) pImage.getColorModel(); int transparent = cm.getTransparentPixel(); if (transparent >= 0) { return new Color(cm.getRGB(transparent), false); } } return null; }
/** * Get player color * * @param playerId the player ID * @return the player color */ public static Color getPlayerColor(short playerId) { return new Color(readPalette().getRGB(35 + playerId)); } }
Color getColor(int index){ IndexColorModel cm = (IndexColorModel)imp.getProcessor().getColorModel(); return new Color(cm.getRGB(index)); }
Color getColor(int index){ IndexColorModel cm = (IndexColorModel)imp.getProcessor().getColorModel(); return new Color(cm.getRGB(index)); }
/** * Gets the 32-bit color in 0xAARRGGBB format for the specified value. * This method uses the index color model. * @param f the value to be mapped to a color. * @return the pixel. */ public int getARGB(float f) { return getColorModel().getRGB(getIndex(f)); }
final void createIndexedImageInfo(ColorModel colorModel) { final IndexColorModel indexColorModel = (IndexColorModel) colorModel; indexCoding = new IndexCoding("color_map"); final int colorCount = indexColorModel.getMapSize(); final ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[colorCount]; for (int j = 0; j < colorCount; j++) { final String name = "I%3d"; indexCoding.addIndex(String.format(name, j), j, ""); points[j] = new ColorPaletteDef.Point(j, new Color(indexColorModel.getRGB(j)), name); } imageInfo = new ImageInfo(new ColorPaletteDef(points, points.length)); }
private static ImageInfo createIndexedImageInfo(Product product, Band band, IndexColorModel colorModel) { final IndexCoding indexCoding = new IndexCoding("color_map"); final int colorCount = colorModel.getMapSize(); final ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[colorCount]; for (int j = 0; j < colorCount; j++) { final String name = String.format("I%3d", j); indexCoding.addIndex(name, j, ""); points[j] = new ColorPaletteDef.Point(j, new Color(colorModel.getRGB(j)), name); } product.getIndexCodingGroup().add(indexCoding); band.setSampleCoding(indexCoding); return new ImageInfo(new ColorPaletteDef(points, points.length)); }
BufferedImage createPaletteImage(final BMHDChunk header, boolean isEHB) throws IIOException { // Create a 1 x colors.length image IndexColorModel cm = getIndexColorModel(header, isEHB); WritableRaster raster = cm.createCompatibleWritableRaster(cm.getMapSize(), 1); byte[] pixel = null; for (int x = 0; x < cm.getMapSize(); x++) { pixel = (byte[]) cm.getDataElements(cm.getRGB(x), pixel); raster.setDataElements(x, 0, pixel); } return new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); }