Java Code Examples for java.awt.image.IndexColorModel#getBlues()
The following examples show how to use
java.awt.image.IndexColorModel#getBlues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JFIFMarkerSegment.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
void write(ImageOutputStream ios, JPEGImageWriter writer) throws IOException { super.write(ios, writer); // width and height // Write the palette (must be 768 bytes) byte [] palette = new byte[768]; IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel(); byte [] reds = new byte [256]; byte [] greens = new byte [256]; byte [] blues = new byte [256]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); for (int i = 0; i < 256; i++) { palette[i*3] = reds[i]; palette[i*3+1] = greens[i]; palette[i*3+2] = blues[i]; } ios.write(palette); writePixels(ios, writer); }
Example 2
Source File: GIFImageReader.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static synchronized byte[] getDefaultPalette() { if (defaultPalette == null) { BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED); IndexColorModel icm = (IndexColorModel) img.getColorModel(); final int size = icm.getMapSize(); byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; icm.getReds(r); icm.getGreens(g); icm.getBlues(b); defaultPalette = new byte[size * 3]; for (int i = 0; i < size; i++) { defaultPalette[3 * i + 0] = r[i]; defaultPalette[3 * i + 1] = g[i]; defaultPalette[3 * i + 2] = b[i]; } } return defaultPalette; }
Example 3
Source File: JFIFMarkerSegment.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
void write(ImageOutputStream ios, JPEGImageWriter writer) throws IOException { super.write(ios, writer); // width and height // Write the palette (must be 768 bytes) byte [] palette = new byte[768]; IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel(); byte [] reds = new byte [256]; byte [] greens = new byte [256]; byte [] blues = new byte [256]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); for (int i = 0; i < 256; i++) { palette[i*3] = reds[i]; palette[i*3+1] = greens[i]; palette[i*3+2] = blues[i]; } ios.write(palette); writePixels(ios, writer); }
Example 4
Source File: JFIFMarkerSegment.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
void write(ImageOutputStream ios, JPEGImageWriter writer) throws IOException { super.write(ios, writer); // width and height // Write the palette (must be 768 bytes) byte [] palette = new byte[768]; IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel(); byte [] reds = new byte [256]; byte [] greens = new byte [256]; byte [] blues = new byte [256]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); for (int i = 0; i < 256; i++) { palette[i*3] = reds[i]; palette[i*3+1] = greens[i]; palette[i*3+2] = blues[i]; } ios.write(palette); writePixels(ios, writer); }
Example 5
Source File: GIFImageReader.java From JDKSourceCode1.8 with MIT License | 6 votes |
private static synchronized byte[] getDefaultPalette() { if (defaultPalette == null) { BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED); IndexColorModel icm = (IndexColorModel) img.getColorModel(); final int size = icm.getMapSize(); byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; icm.getReds(r); icm.getGreens(g); icm.getBlues(b); defaultPalette = new byte[size * 3]; for (int i = 0; i < size; i++) { defaultPalette[3 * i + 0] = r[i]; defaultPalette[3 * i + 1] = g[i]; defaultPalette[3 * i + 2] = b[i]; } } return defaultPalette; }
Example 6
Source File: JFIFMarkerSegment.java From JDKSourceCode1.8 with MIT License | 6 votes |
void write(ImageOutputStream ios, JPEGImageWriter writer) throws IOException { super.write(ios, writer); // width and height // Write the palette (must be 768 bytes) byte [] palette = new byte[768]; IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel(); byte [] reds = new byte [256]; byte [] greens = new byte [256]; byte [] blues = new byte [256]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); for (int i = 0; i < 256; i++) { palette[i*3] = reds[i]; palette[i*3+1] = greens[i]; palette[i*3+2] = blues[i]; } ios.write(palette); writePixels(ios, writer); }
Example 7
Source File: GIFImageReader.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static synchronized byte[] getDefaultPalette() { if (defaultPalette == null) { BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED); IndexColorModel icm = (IndexColorModel) img.getColorModel(); final int size = icm.getMapSize(); byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; icm.getReds(r); icm.getGreens(g); icm.getBlues(b); defaultPalette = new byte[size * 3]; for (int i = 0; i < size; i++) { defaultPalette[3 * i + 0] = r[i]; defaultPalette[3 * i + 1] = g[i]; defaultPalette[3 * i + 2] = b[i]; } } return defaultPalette; }
Example 8
Source File: JFIFMarkerSegment.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
void write(ImageOutputStream ios, JPEGImageWriter writer) throws IOException { super.write(ios, writer); // width and height // Write the palette (must be 768 bytes) byte [] palette = new byte[768]; IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel(); byte [] reds = new byte [256]; byte [] greens = new byte [256]; byte [] blues = new byte [256]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); for (int i = 0; i < 256; i++) { palette[i*3] = reds[i]; palette[i*3+1] = greens[i]; palette[i*3+2] = blues[i]; } ios.write(palette); writePixels(ios, writer); }
Example 9
Source File: MainFrame.java From ios-image-util with MIT License | 6 votes |
protected IndexColorModel getIndexColorModel(BufferedImage src) { // index color with transparent ColorModel cm = src.getColorModel(); if (cm instanceof IndexColorModel) { IndexColorModel icm = (IndexColorModel)cm; int mapSize = icm.getMapSize(); byte[] reds = new byte[mapSize]; byte[] greens = new byte[mapSize]; byte[] blues = new byte[mapSize]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); return new IndexColorModel(8, mapSize, reds, greens, blues, 0); } return null; }
Example 10
Source File: GIFImageReader.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static synchronized byte[] getDefaultPalette() { if (defaultPalette == null) { BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED); IndexColorModel icm = (IndexColorModel) img.getColorModel(); final int size = icm.getMapSize(); byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; icm.getReds(r); icm.getGreens(g); icm.getBlues(b); defaultPalette = new byte[size * 3]; for (int i = 0; i < size; i++) { defaultPalette[3 * i + 0] = r[i]; defaultPalette[3 * i + 1] = g[i]; defaultPalette[3 * i + 2] = b[i]; } } return defaultPalette; }
Example 11
Source File: JFIFMarkerSegment.java From hottub with GNU General Public License v2.0 | 6 votes |
void write(ImageOutputStream ios, JPEGImageWriter writer) throws IOException { super.write(ios, writer); // width and height // Write the palette (must be 768 bytes) byte [] palette = new byte[768]; IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel(); byte [] reds = new byte [256]; byte [] greens = new byte [256]; byte [] blues = new byte [256]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); for (int i = 0; i < 256; i++) { palette[i*3] = reds[i]; palette[i*3+1] = greens[i]; palette[i*3+2] = blues[i]; } ios.write(palette); writePixels(ios, writer); }
Example 12
Source File: JFIFMarkerSegment.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
void write(ImageOutputStream ios, JPEGImageWriter writer) throws IOException { super.write(ios, writer); // width and height // Write the palette (must be 768 bytes) byte [] palette = new byte[768]; IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel(); byte [] reds = new byte [256]; byte [] greens = new byte [256]; byte [] blues = new byte [256]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); for (int i = 0; i < 256; i++) { palette[i*3] = reds[i]; palette[i*3+1] = greens[i]; palette[i*3+2] = blues[i]; } ios.write(palette); writePixels(ios, writer); }
Example 13
Source File: GIFImageReader.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
private static synchronized byte[] getDefaultPalette() { if (defaultPalette == null) { BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED); IndexColorModel icm = (IndexColorModel) img.getColorModel(); final int size = icm.getMapSize(); byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; icm.getReds(r); icm.getGreens(g); icm.getBlues(b); defaultPalette = new byte[size * 3]; for (int i = 0; i < size; i++) { defaultPalette[3 * i + 0] = r[i]; defaultPalette[3 * i + 1] = g[i]; defaultPalette[3 * i + 2] = b[i]; } } return defaultPalette; }
Example 14
Source File: PaletteBox.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 5 votes |
/** Gets the LUT from the <code>IndexColorModel</code> as an two-dimensional * byte array. */ private static byte[][] getLUT(IndexColorModel icm) { int[] comp = icm.getComponentSize(); int size = icm.getMapSize(); byte[][] lut = new byte[comp.length][size]; icm.getReds(lut[0]); icm.getGreens(lut[1]); icm.getBlues(lut[2]); if (comp.length == 4) icm.getAlphas(lut[3]); return lut; }
Example 15
Source File: AWTImageTools.java From scifio with BSD 2-Clause "Simplified" License | 5 votes |
/** Converts an IndexColorModel to a 2D byte array. */ public static byte[][] get8BitLookupTable(final ColorModel model) { if (!(model instanceof IndexColorModel)) return null; final IndexColorModel m = (IndexColorModel) model; final byte[][] lut = new byte[3][m.getMapSize()]; m.getReds(lut[0]); m.getGreens(lut[1]); m.getBlues(lut[2]); return lut; }
Example 16
Source File: GIFImageWriter.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Create a color table from the image ColorModel and SampleModel. */ private static byte[] createColorTable(ColorModel colorModel, SampleModel sampleModel) { byte[] colorTable; if (colorModel instanceof IndexColorModel) { IndexColorModel icm = (IndexColorModel)colorModel; int mapSize = icm.getMapSize(); /** * The GIF image format assumes that size of image palette * is power of two. We will use closest larger power of two * as size of color table. */ int ctSize = getGifPaletteSize(mapSize); byte[] reds = new byte[ctSize]; byte[] greens = new byte[ctSize]; byte[] blues = new byte[ctSize]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); /** * fill tail of color component arrays by replica of first color * in order to avoid appearance of extra colors in the color table */ for (int i = mapSize; i < ctSize; i++) { reds[i] = reds[0]; greens[i] = greens[0]; blues[i] = blues[0]; } colorTable = new byte[3*ctSize]; int idx = 0; for (int i = 0; i < ctSize; i++) { colorTable[idx++] = reds[i]; colorTable[idx++] = greens[i]; colorTable[idx++] = blues[i]; } } else if (sampleModel.getNumBands() == 1) { // create gray-scaled color table for single-banded images int numBits = sampleModel.getSampleSize()[0]; if (numBits > 8) { numBits = 8; } int colorTableLength = 3*(1 << numBits); colorTable = new byte[colorTableLength]; for (int i = 0; i < colorTableLength; i++) { colorTable[i] = (byte)(i/3); } } else { // We do not have enough information here // to create well-fit color table for RGB image. colorTable = null; } return colorTable; }
Example 17
Source File: GIFImageWriter.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Create a color table from the image ColorModel and SampleModel. */ private static byte[] createColorTable(ColorModel colorModel, SampleModel sampleModel) { byte[] colorTable; if (colorModel instanceof IndexColorModel) { IndexColorModel icm = (IndexColorModel)colorModel; int mapSize = icm.getMapSize(); /** * The GIF image format assumes that size of image palette * is power of two. We will use closest larger power of two * as size of color table. */ int ctSize = getGifPaletteSize(mapSize); byte[] reds = new byte[ctSize]; byte[] greens = new byte[ctSize]; byte[] blues = new byte[ctSize]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); /** * fill tail of color component arrays by replica of first color * in order to avoid appearance of extra colors in the color table */ for (int i = mapSize; i < ctSize; i++) { reds[i] = reds[0]; greens[i] = greens[0]; blues[i] = blues[0]; } colorTable = new byte[3*ctSize]; int idx = 0; for (int i = 0; i < ctSize; i++) { colorTable[idx++] = reds[i]; colorTable[idx++] = greens[i]; colorTable[idx++] = blues[i]; } } else if (sampleModel.getNumBands() == 1) { // create gray-scaled color table for single-banded images int numBits = sampleModel.getSampleSize()[0]; if (numBits > 8) { numBits = 8; } int colorTableLength = 3*(1 << numBits); colorTable = new byte[colorTableLength]; for (int i = 0; i < colorTableLength; i++) { colorTable[i] = (byte)(i/3); } } else { // We do not have enough information here // to create well-fit color table for RGB image. colorTable = null; } return colorTable; }
Example 18
Source File: GIFImageWriter.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Create a color table from the image ColorModel and SampleModel. */ private static byte[] createColorTable(ColorModel colorModel, SampleModel sampleModel) { byte[] colorTable; if (colorModel instanceof IndexColorModel) { IndexColorModel icm = (IndexColorModel)colorModel; int mapSize = icm.getMapSize(); /** * The GIF image format assumes that size of image palette * is power of two. We will use closest larger power of two * as size of color table. */ int ctSize = getGifPaletteSize(mapSize); byte[] reds = new byte[ctSize]; byte[] greens = new byte[ctSize]; byte[] blues = new byte[ctSize]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); /** * fill tail of color component arrays by replica of first color * in order to avoid appearance of extra colors in the color table */ for (int i = mapSize; i < ctSize; i++) { reds[i] = reds[0]; greens[i] = greens[0]; blues[i] = blues[0]; } colorTable = new byte[3*ctSize]; int idx = 0; for (int i = 0; i < ctSize; i++) { colorTable[idx++] = reds[i]; colorTable[idx++] = greens[i]; colorTable[idx++] = blues[i]; } } else if (sampleModel.getNumBands() == 1) { // create gray-scaled color table for single-banded images int numBits = sampleModel.getSampleSize()[0]; if (numBits > 8) { numBits = 8; } int colorTableLength = 3*(1 << numBits); colorTable = new byte[colorTableLength]; for (int i = 0; i < colorTableLength; i++) { colorTable[i] = (byte)(i/3); } } else { // We do not have enough information here // to create well-fit color table for RGB image. colorTable = null; } return colorTable; }
Example 19
Source File: GIFImageWriter.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Create a color table from the image ColorModel and SampleModel. */ private static byte[] createColorTable(ColorModel colorModel, SampleModel sampleModel) { byte[] colorTable; if (colorModel instanceof IndexColorModel) { IndexColorModel icm = (IndexColorModel)colorModel; int mapSize = icm.getMapSize(); /** * The GIF image format assumes that size of image palette * is power of two. We will use closest larger power of two * as size of color table. */ int ctSize = getGifPaletteSize(mapSize); byte[] reds = new byte[ctSize]; byte[] greens = new byte[ctSize]; byte[] blues = new byte[ctSize]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); /** * fill tail of color component arrays by replica of first color * in order to avoid appearance of extra colors in the color table */ for (int i = mapSize; i < ctSize; i++) { reds[i] = reds[0]; greens[i] = greens[0]; blues[i] = blues[0]; } colorTable = new byte[3*ctSize]; int idx = 0; for (int i = 0; i < ctSize; i++) { colorTable[idx++] = reds[i]; colorTable[idx++] = greens[i]; colorTable[idx++] = blues[i]; } } else if (sampleModel.getNumBands() == 1) { // create gray-scaled color table for single-banded images int numBits = sampleModel.getSampleSize()[0]; if (numBits > 8) { numBits = 8; } int colorTableLength = 3*(1 << numBits); colorTable = new byte[colorTableLength]; for (int i = 0; i < colorTableLength; i++) { colorTable[i] = (byte)(i/3); } } else { // We do not have enough information here // to create well-fit color table for RGB image. colorTable = null; } return colorTable; }
Example 20
Source File: GIFImageWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Create a color table from the image ColorModel and SampleModel. */ private static byte[] createColorTable(ColorModel colorModel, SampleModel sampleModel) { byte[] colorTable; if (colorModel instanceof IndexColorModel) { IndexColorModel icm = (IndexColorModel)colorModel; int mapSize = icm.getMapSize(); /** * The GIF image format assumes that size of image palette * is power of two. We will use closest larger power of two * as size of color table. */ int ctSize = getGifPaletteSize(mapSize); byte[] reds = new byte[ctSize]; byte[] greens = new byte[ctSize]; byte[] blues = new byte[ctSize]; icm.getReds(reds); icm.getGreens(greens); icm.getBlues(blues); /** * fill tail of color component arrays by replica of first color * in order to avoid appearance of extra colors in the color table */ for (int i = mapSize; i < ctSize; i++) { reds[i] = reds[0]; greens[i] = greens[0]; blues[i] = blues[0]; } colorTable = new byte[3*ctSize]; int idx = 0; for (int i = 0; i < ctSize; i++) { colorTable[idx++] = reds[i]; colorTable[idx++] = greens[i]; colorTable[idx++] = blues[i]; } } else if (sampleModel.getNumBands() == 1) { // create gray-scaled color table for single-banded images int numBits = sampleModel.getSampleSize()[0]; if (numBits > 8) { numBits = 8; } int colorTableLength = 3*(1 << numBits); colorTable = new byte[colorTableLength]; for (int i = 0; i < colorTableLength; i++) { colorTable[i] = (byte)(i/3); } } else { // We do not have enough information here // to create well-fit color table for RGB image. colorTable = null; } return colorTable; }