Java Code Examples for java.awt.image.IndexColorModel#getTransparentPixel()
The following examples show how to use
java.awt.image.IndexColorModel#getTransparentPixel() .
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: ColorModelPatch.java From sis with Apache License 2.0 | 5 votes |
/** * Returns {@code true} if the given color models are equal. The {@link ColorModel} class * defines an {@code equals} method, but as of Java 6 that method does not compare every * attributes. For example it does not compare the color space and the transfer type, so * we have to compare them here. * * @param cm1 the first color model. * @param cm2 the second color model. * @return {@code true} if the two color models are equal. */ private static boolean equals(final ColorModel cm1, final ColorModel cm2) { if (cm1 == cm2) { return true; } if (cm1 != null && cm1.equals(cm2) && cm1.getClass().equals(cm2.getClass()) && cm1.getTransferType() == cm2.getTransferType() && Objects.equals(cm1.getColorSpace(), cm2.getColorSpace())) { if (cm1 instanceof IndexColorModel) { final IndexColorModel icm1 = (IndexColorModel) cm1; final IndexColorModel icm2 = (IndexColorModel) cm2; final int size = icm1.getMapSize(); if (icm2.getMapSize() == size && icm1.getTransparentPixel() == icm2.getTransparentPixel() && Objects.equals(icm1.getValidPixels(), icm2.getValidPixels())) { for (int i=0; i<size; i++) { if (icm1.getRGB(i) != icm2.getRGB(i)) { return false; } } } if (cm1 instanceof MultiBandsIndexColorModel) { final MultiBandsIndexColorModel micm1 = (MultiBandsIndexColorModel) cm1; final MultiBandsIndexColorModel micm2 = (MultiBandsIndexColorModel) cm2; if (micm1.numBands != micm2.numBands || micm1.visibleBand != micm2.visibleBand) { return false; } } } return true; } return false; }
Example 2
Source File: ColorLUT.java From pumpernickel with MIT License | 5 votes |
/** Create a ColorLUT from a <code>IndexColorModel</code>. */ public ColorLUT(IndexColorModel icm) { this.indexColorModel = icm; for (int a = 0; a < icm.getMapSize(); a++) { if (a != icm.getTransparentPixel()) { int red = icm.getRed(a); int green = icm.getGreen(a); int blue = icm.getBlue(a); addRGB(red, green, blue, a); } } }
Example 3
Source File: ImageRepresentation.java From hottub with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 4
Source File: ImageRepresentation.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 5
Source File: ImageRepresentation.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 6
Source File: ImageRepresentation.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 7
Source File: MinimalGifEncoder.java From pumpernickel with MIT License | 4 votes |
@Override public void writeImage(OutputStream out, BufferedImage image, int frameDurationInCentiseconds, IndexColorModel globalColorModel, boolean writeLocalColorTable) throws IOException { if (frameDurationInCentiseconds >= 0 || globalColorModel.getTransparentPixel() != -1) { if (frameDurationInCentiseconds < 0) frameDurationInCentiseconds = 0; GifGraphicControlExtension gce = new GifGraphicControlExtension( frameDurationInCentiseconds, DisposalMethod.RESTORE_BACKGROUND, globalColorModel.getTransparentPixel()); gce.write(out); } int localColorSize = 0; if (writeLocalColorTable) { localColorSize = globalColorModel.getMapSize(); int k = 2; while (localColorSize > k) { k *= 2; } if (k > 256) throw new IllegalArgumentException("Illegal number of colors (" + localColorSize + "). There can only be 256 at most."); localColorSize = k; } Dimension d = new Dimension(image.getWidth(), image.getHeight()); GifImageDescriptor id = new GifImageDescriptor(0, 0, d.width, d.height, false, localColorSize); id.write(out); if (localColorSize > 0) { GifLocalColorTable ct = new GifLocalColorTable(globalColorModel); ct.write(out); } GifImageDataBlock dataBlock = new GifImageDataBlock(image, globalColorModel); dataBlock.write(out); }
Example 8
Source File: ImageRepresentation.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 9
Source File: ImageRepresentation.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 10
Source File: ImageRepresentation.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 11
Source File: ImageRepresentation.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 12
Source File: ImageRepresentation.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == Transparency.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 13
Source File: ImageRepresentation.java From Bytecoder with Apache License 2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == Transparency.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 14
Source File: ImageRepresentation.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 15
Source File: ImageRepresentation.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 16
Source File: ImageRepresentation.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 17
Source File: ImageRepresentation.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }