Examples of IndexColorModel


Examples of java.awt.image.IndexColorModel

                    }
                }

                int numBits =
                    sm.getDataType() == DataBuffer.TYPE_BYTE ? 8 : 16;
                il.setColorModel(new IndexColorModel(numBits, maxIndex + 1,
                                                     cmap[0], cmap[1],
                                                     cmap[2]));
            }
        }
View Full Code Here

Examples of java.awt.image.IndexColorModel

    public ColorModel getColorModel() {
        if (colorMap == null)
            train();
        if (colorModel == null)
            colorModel =
                new IndexColorModel(8, colorMap.getByteData(0).length,
                                    colorMap.getByteData(0),
                                    colorMap.getByteData(1),
                                    colorMap.getByteData(2));
        return colorModel;
    }
View Full Code Here

Examples of java.awt.image.IndexColorModel

         * Note, in this case, the source should have an integral data type.
         * And dest always has data type byte.
         */
        ColorModel srcColorModel = source.getColorModel();
        if (srcColorModel instanceof IndexColorModel) {
            IndexColorModel icm = (IndexColorModel)srcColorModel;
            ctable = new byte[3][icm.getMapSize()];
            icm.getReds(ctable[0]);
            icm.getGreens(ctable[1]);
            icm.getBlues(ctable[2]);
        }
    }
View Full Code Here

Examples of java.awt.image.IndexColorModel

            final int transparency = backColor != Gripper.ALPHA ? Transparency.OPAQUE : Transparency.BITMASK;
            image = gc.createCompatibleImage(IMAGE_SIZE, IMAGE_SIZE, transparency);

        } else {
            int cmap[] = {backColor.getRGB(), topColor.getRGB(), shadowColor.getRGB()};
            IndexColorModel icm = new IndexColorModel(8, 3, cmap, 0, false, backColor == Gripper.ALPHA ? 0 : -1, DataBuffer.TYPE_BYTE);
            image = new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_BYTE_INDEXED, icm);
        }
    }
View Full Code Here

Examples of java.awt.image.IndexColorModel

        ColorModel cm;
        MemoryImageSource mis;
        if (noOfEntries > 0)
        {
            // There is a color palette; create an IndexColorModel
            cm = new IndexColorModel(bitsPerPixel, noOfEntries, r, g, b);
        }
        else
        {
            // There is no palette; use the default RGB color model
            cm = ColorModel.getRGBdefault();
View Full Code Here

Examples of java.awt.image.IndexColorModel

            r[i] = (byte)((val>>16)&0xFF);
            g[i] = (byte)((val>> 8)&0xFF);
            b[i] = (byte)((val    )&0xFF);
        }

  IndexColorModel model=new IndexColorModel(4,256,r,g,b);
  BufferedImage indexed=new BufferedImage
            (w, h, BufferedImage.TYPE_BYTE_INDEXED,model);
  Graphics2D g2d=indexed.createGraphics();
  g2d.setRenderingHint
            (RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_ENABLE);
View Full Code Here

Examples of java.awt.image.IndexColorModel

        // The JDK doesn't seem to dither the image correctly if I go
        // below 8bits per pixel.  So I dither to an 8bit pallete
        // image that only has nCubes colors.  Then I copy the data to
        // a lower bit depth image that I return.
        IndexColorModel icm=new IndexColorModel(8,nCubes,r,g,b);
        indexed =new BufferedImage
            (w, h, BufferedImage.TYPE_BYTE_INDEXED, icm);
        Graphics2D g2d=indexed.createGraphics();
        g2d.setRenderingHint
            (RenderingHints.KEY_DITHERING,
             RenderingHints.VALUE_DITHER_ENABLE);
        g2d.drawImage(bi, 0, 0, null);
        g2d.dispose();


        int bits;
        for (bits=1; bits <=8; bits++) {
            if ((1<<bits) >= nCubes) break;
        }
        // System.out.println("Bits: " + bits + " Cubes: " + nCubes);

        if (bits > 4)
            // 8 bit image we are done...
            return indexed;

        // Create our low bit depth image...
        if (bits ==3) bits = 4;
        ColorModel cm=new IndexColorModel(bits,nCubes,r,g,b);
        SampleModel sm = new MultiPixelPackedSampleModel
            (DataBuffer.TYPE_BYTE, w, h, bits);
        WritableRaster ras = Raster.createWritableRaster
            (sm, new Point(0,0));
View Full Code Here

Examples of java.awt.image.IndexColorModel

        SampleModel sm = theTile.getSampleModel();
  ColorModel  cm;

        if ((colorType == PNG_COLOR_PALETTE) && !expandPalette) {
            if (outputHasAlphaPalette) {
                cm = new IndexColorModel(bitDepth,
                                                 paletteEntries,
                                                 redPalette,
                                                 greenPalette,
                                                 bluePalette,
                                                 alphaPalette);
            } else {
                cm = new IndexColorModel(bitDepth,
                                                 paletteEntries,
                                                 redPalette,
                                                 greenPalette,
                                                 bluePalette);
            }
        } else if ((colorType == PNG_COLOR_GRAY) &&
                   (bitDepth < 8) && !output8BitGray) {
            byte[] palette = expandBits[bitDepth];
            cm = new IndexColorModel(bitDepth,
                                             palette.length,
                                             palette,
                                             palette,
                                             palette);
        } else {
View Full Code Here

Examples of java.awt.image.IndexColorModel

            colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                    ColorModel.OPAQUE, DataBuffer.TYPE_BYTE);
            break;
        case PNG_COLOR_PALETTE:
            if (hasAlphaPalette) {
                colorModel = new IndexColorModel(bitDepth, paletteEntries, redPalette, greenPalette,
                        bluePalette, alphaPalette);
            } else {
                colorModel = new IndexColorModel(bitDepth, paletteEntries, redPalette, greenPalette,
                        bluePalette);
            }
            break;
        case PNG_COLOR_GRAY_ALPHA:
            if (hasPalette) {
View Full Code Here

Examples of java.awt.image.IndexColorModel

        decodeImage(interlaceMethod == 1);
        sampleModel = theTile.getSampleModel();

        if ((colorType == PNG_COLOR_PALETTE) && !expandPalette) {
            if (outputHasAlphaPalette) {
                colorModel = new IndexColorModel(bitDepth,
                                                 paletteEntries,
                                                 redPalette,
                                                 greenPalette,
                                                 bluePalette,
                                                 alphaPalette);
            } else {
                colorModel = new IndexColorModel(bitDepth,
                                                 paletteEntries,
                                                 redPalette,
                                                 greenPalette,
                                                 bluePalette);
            }
        } else if ((colorType == PNG_COLOR_GRAY) &&
                   (bitDepth < 8) && !output8BitGray) {
            byte[] palette = expandBits[bitDepth];
            colorModel = new IndexColorModel(bitDepth,
                                             palette.length,
                                             palette,
                                             palette,
                                             palette);
        } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.