@Override public final int getRed(final int pixel) { return icm.getRed(pixel); }
final short[][] data = new short[numDestinationBands][mapSize]; for (int i = 0; i < mapSize; i++) { data[0][i] = (short) icm.getRed(i); if (numDestinationBands >= 2)
void writeChunk(final DataOutput pOutput) throws IOException { pOutput.writeInt(chunkId); pOutput.writeInt(chunkLength); final int length = model.getMapSize(); for (int i = 0; i < length; i++) { pOutput.writeByte(model.getRed(i)); pOutput.writeByte(model.getGreen(i)); pOutput.writeByte(model.getBlue(i)); } if (chunkLength % 2 != 0) { pOutput.writeByte(0); // PAD } }
lastRed = colorModel.getRed(paletteIndex); lastGreen = colorModel.getGreen(paletteIndex); lastBlue = colorModel.getBlue(paletteIndex);
/** * Looks for the specified color in the color model * * @param bgColor The color to be searched * @param icm The color model to be searched into * @return The index of the color in the color model, or -1 if not found */ public static int findColorIndex(Color bgColor, IndexColorModel icm) { if (bgColor == null) throw new NullPointerException((Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "bgColor"))); if (icm == null) throw new NullPointerException((Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "icm"))); final int r = bgColor.getRed(); final int g = bgColor.getGreen(); final int b = bgColor.getBlue(); final int a = bgColor.getAlpha(); final int size = icm.getMapSize(); for (int i = 0; i < size; i++) { if (r == icm.getRed(i) && g == icm.getGreen(i) && b == icm.getBlue(i) && (a == icm.getAlpha(i) || !icm.hasAlpha())) return i; } return -1; }
private IIOMetadataNode createPaletteNode() { IIOMetadataNode palette = new IIOMetadataNode("Palette"); IndexColorModel cm = colorData.getIndexColorModel(); for (int i = 0; i < cm.getMapSize(); i++) { IIOMetadataNode entry = new IIOMetadataNode("PaletteEntry"); entry.setAttribute("index", Integer.toString(i)); entry.setAttribute("red", Integer.toString(cm.getRed(i))); entry.setAttribute("green", Integer.toString(cm.getGreen(i))); entry.setAttribute("blue", Integer.toString(cm.getBlue(i))); palette.appendChild(entry); } return palette; }
/** * Color palette associated with the sample dimension. A color palette can have any number of * colors. See palette interpretation for meaning of the palette entries. If the grid coverage * has no color palette, {@code null} will be returned. * * @return The color palette associated with the sample dimension. * @see #getPaletteInterpretation * @see #getColorInterpretation * @see IndexColorModel * @deprecated No replacement. */ public int[][] getPalette() { final ColorModel color = getColorModel(); if (color instanceof IndexColorModel) { final IndexColorModel cm = (IndexColorModel) color; final int[][] colors = new int[cm.getMapSize()][]; for (int i = 0; i < colors.length; i++) { colors[i] = new int[] {cm.getRed(i), cm.getGreen(i), cm.getBlue(i)}; } return colors; } return null; }
for (int i = colors.getMapSize(); --i >= 0; ) { if (i != exclude) { RGB[0] = colors.getRed(i) / 255f; RGB[1] = colors.getGreen(i) / 255f; RGB[2] = colors.getBlue(i) / 255f;
if (green != icm.getRed(i) || green != icm.getBlue(i)) { return false;
paletteEntry.setAttribute("index", Integer.toString(i)); paletteEntry.setAttribute("red", Integer.toString(colorMap.getRed(i))); paletteEntry.setAttribute("green", Integer.toString(colorMap.getGreen(i))); paletteEntry.setAttribute("blue", Integer.toString(colorMap.getBlue(i)));
@Override public final int getRed(final int pixel) { return icm.getRed(pixel); }
final int a = colors.getAlpha(i); if (a <= alpha) { RGB[0] = colors.getRed(i) / 255f; RGB[1] = colors.getGreen(i) / 255f; RGB[2] = colors.getBlue(i) / 255f;
paletteEntry.setAttribute("index", Integer.toString(i)); paletteEntry.setAttribute("red", Integer.toString(palette.getRed(i))); paletteEntry.setAttribute("green", Integer.toString(palette.getGreen(i))); paletteEntry.setAttribute("blue", Integer.toString(palette.getBlue(i)));
void writeChunk(final DataOutput pOutput) throws IOException { pOutput.writeInt(chunkId); pOutput.writeInt(chunkLength); final int length = model.getMapSize(); for (int i = 0; i < length; i++) { pOutput.writeByte(model.getRed(i)); pOutput.writeByte(model.getGreen(i)); pOutput.writeByte(model.getBlue(i)); } if (chunkLength % 2 != 0) { pOutput.writeByte(0); // PAD } }
@Override public void mutate( FloatBuffer floatBuffer, int dim ) { for ( int i = 0; i < dim; i++ ) { floatBuffer.put( _colorModel.getRed( i ) / 255.0f ); floatBuffer.put( _colorModel.getGreen( i ) / 255.0f ); floatBuffer.put( _colorModel.getBlue( i ) / 255.0f ); floatBuffer.put( _colorModel.getAlpha( i ) / 255.0f ); } } } );
private byte[] createLargePalette(ColorModel cm){ byte[] palette = new byte[256*3]; if(!(cm instanceof IndexColorModel)) return palette; IndexColorModel icm = (IndexColorModel) cm; for(int i=0,offset=0;i<icm.getMapSize();i++) { palette[offset++] = (byte) icm.getRed(i); palette[offset++] = (byte) icm.getGreen(i); palette[offset++] = (byte) icm.getBlue(i); } return palette; } }
private byte[] createLargePalette(ColorModel cm){ byte[] palette = new byte[256*3]; if(!(cm instanceof IndexColorModel)) return palette; IndexColorModel icm = (IndexColorModel) cm; for(int i=0,offset=0;i<icm.getMapSize();i++) { palette[offset++] = (byte) icm.getRed(i); palette[offset++] = (byte) icm.getGreen(i); palette[offset++] = (byte) icm.getBlue(i); } return palette; } }
/** * Writes the color map (ILBM CMAP). */ private void writeCMAP(IFFOutputStream out, BitmapImage img) throws IOException { out.pushDataChunk("CMAP"); IndexColorModel cm = (IndexColorModel) img.getPlanarColorModel(); for (int i = 0, n = cm.getMapSize(); i < n; ++i) { out.writeUBYTE(cm.getRed(i)); out.writeUBYTE(cm.getGreen(i)); out.writeUBYTE(cm.getBlue(i)); } out.popChunk(); }