Package java.awt.image

Examples of java.awt.image.ColorModel$SRGBColorModel


        // BufferedImage
        // with its actual (presumably correct) Colorspace.
        // use this when the image is mislabeled, presumably having been
        // wrongly assumed to be sRGB

        ColorModel cm = deriveColorModel(bi, cs);

        return relabelColorSpace(bi, cm);

    }
View Full Code Here


    }

    public BufferedImage convertTosRGB(BufferedImage bi) {
        ColorSpace cs_sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);

        ColorModel srgbCM = ColorModel.getRGBdefault();
        cs_sRGB = srgbCM.getColorSpace();

        return convertToColorSpace(bi, cs_sRGB);
    }
View Full Code Here

    protected BufferedImage convertFromColorSpace(BufferedImage bi,
            ColorSpace from) {
        ColorSpace cs_sRGB;

        ColorModel srgbCM = ColorModel.getRGBdefault();
        cs_sRGB = srgbCM.getColorSpace();

        return convertBetweenColorSpaces(bi, from, cs_sRGB);

    }
View Full Code Here

                throw new ImageReadException("Parsing XBM file failed, " +
                        "punctuation error");
        }

        int[] palette = {0xffffff, 0x000000};
        ColorModel colorModel = new IndexColorModel(1, 2,
                palette, 0, false, -1, DataBuffer.TYPE_BYTE);
        DataBufferByte dataBuffer = new DataBufferByte(imageData, imageData.length);
        WritableRaster raster = WritableRaster.createPackedRaster(dataBuffer,
                xbmHeader.width, xbmHeader.height, 1, null);
        BufferedImage image = new BufferedImage(colorModel, raster,
                colorModel.isAlphaPremultiplied(), new Properties());
        return image;
    }
View Full Code Here

            }
            DataBufferByte dataBuffer = new DataBufferByte(image, image[0].length);
            WritableRaster raster = WritableRaster.createBandedRaster(dataBuffer,
                    xSize, ySize, xSize, new int[]{0,1,2},
                    new int[]{0,0,0}, null);
            ColorModel colorModel = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
            return new BufferedImage(colorModel, raster,
                    colorModel.isAlphaPremultiplied(), new Properties());
        }
        else if ((pcxHeader.bitsPerPixel == 24 && pcxHeader.nPlanes == 1) ||
                (pcxHeader.bitsPerPixel == 32 && pcxHeader.nPlanes == 1))
        {
            int rowLength = 3 * xSize;
            byte[] image = new byte[rowLength * ySize];
            for (int y = 0; y < ySize; y++)
            {
                readScanLine(pcxHeader, is, scanline);
                if (pcxHeader.bitsPerPixel == 24)
                    System.arraycopy(scanline, 0, image, y*rowLength, rowLength);
                else
                {
                    for (int x = 0; x < xSize; x++)
                    {
                        image[y*rowLength + 3*x] = scanline[4*x];
                        image[y*rowLength + 3*x + 1] = scanline[4*x + 1];
                        image[y*rowLength + 3*x + 2] = scanline[4*x + 2];
                    }
                }
            }
            DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
            WritableRaster raster = WritableRaster.createInterleavedRaster(
                    dataBuffer, xSize, ySize, rowLength, 3,
                    new int[]{2,1,0}, null);
            ColorModel colorModel = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
            return new BufferedImage(colorModel, raster,
                    colorModel.isAlphaPremultiplied(), new Properties());
        }
        else
        {
            throw new ImageReadException("Invalid/unsupported image with bitsPerPixel "
                    + pcxHeader.bitsPerPixel + " and planes " + pcxHeader.nPlanes);
View Full Code Here

                Boolean is_srgb = new IccProfileParser().issRGB(icc_profile);
                if (is_srgb == null || !is_srgb.booleanValue())
                {
                    ICC_ColorSpace cs = new ICC_ColorSpace(icc_profile);

                    ColorModel srgbCM = ColorModel.getRGBdefault();
                    ColorSpace cs_sRGB = srgbCM.getColorSpace();

                    result = new ColorTools().convertBetweenColorSpaces(result,
                            cs, cs_sRGB);
                }
            }
View Full Code Here

    }

    private BufferedImage readXpmImage(XpmHeader xpmHeader, BasicCParser cParser)
            throws ImageReadException, IOException
    {
        ColorModel colorModel;
        WritableRaster raster;
        int bpp;
        if (xpmHeader.palette.size() <= (1 << 8))
        {
            int[] palette = new int[xpmHeader.palette.size()];
            for (Iterator it = xpmHeader.palette.entrySet().iterator(); it.hasNext();)
            {
                Map.Entry entry = (Map.Entry)it.next();
                PaletteEntry paletteEntry = (PaletteEntry)entry.getValue();
                palette[paletteEntry.index] = paletteEntry.getBestARGB();
            }
            colorModel = new IndexColorModel(8, xpmHeader.palette.size(),
                    palette, 0, true, -1, DataBuffer.TYPE_BYTE);
            raster = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
                    xpmHeader.width, xpmHeader.height, 1, null);
            bpp = 8;
        }
        else if (xpmHeader.palette.size() <= (1 << 16))
        {
            int[] palette = new int[xpmHeader.palette.size()];
            for (Iterator it = xpmHeader.palette.entrySet().iterator(); it.hasNext();)
            {
                Map.Entry entry = (Map.Entry)it.next();
                PaletteEntry paletteEntry = (PaletteEntry)entry.getValue();
                palette[paletteEntry.index] = paletteEntry.getBestARGB();
            }
            colorModel = new IndexColorModel(16, xpmHeader.palette.size(),
                    palette, 0, true, -1, DataBuffer.TYPE_USHORT);
            raster = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_USHORT,
                    xpmHeader.width, xpmHeader.height, 1, null);
            bpp = 16;
        }
        else
        {
            colorModel = new DirectColorModel(32, 0x00ff0000, 0x0000ff00,
                    0x000000ff, 0xff000000);
            raster = WritableRaster.createPackedRaster(DataBuffer.TYPE_INT,
                    xpmHeader.width, xpmHeader.height,
                    new int[]{0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, null);
            bpp = 32;
        }

        BufferedImage image = new BufferedImage(colorModel, raster,
                colorModel.isAlphaPremultiplied(), new Properties());
        DataBuffer dataBuffer = raster.getDataBuffer();
        StringBuilder row = new StringBuilder();
        boolean hasMore = true;
        for (int y = 0; y < xpmHeader.height; y++)
        {
View Full Code Here

        return 1;
    }

    public int countTransparentColors(BufferedImage src)
    {
        ColorModel cm = src.getColorModel();
        if (!cm.hasAlpha())
            return 0;

        int width = src.getWidth();
        int height = src.getHeight();
View Full Code Here

     */
    public ColorModel createColorModel( int bpc ) throws IOException
    {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        int[] nBits = {bpc};
        ColorModel colorModel = new ComponentColorModel(cs, nBits, false,false,
                Transparency.OPAQUE,DataBuffer.TYPE_BYTE);
        return colorModel;

    }
View Full Code Here

    {
        int size = getHighValue();
        byte[] index = getLookupData();
        //for (int i=0;i<index.length;i++) System.out.print(index[i]+" ");
       
        ColorModel cm = new IndexColorModel(bpc, size+1, index,0,false);
        return cm;
    }
View Full Code Here

TOP

Related Classes of java.awt.image.ColorModel$SRGBColorModel

Copyright © 2018 www.massapicom. 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.