Package java.awt.color

Examples of java.awt.color.ColorSpace


            Profile cmsInProfile = new Profile(inProfile);

            BufferedImage inputImage = ImageIO.read(new File("/Stuff/Reference/small-q60-adobergb.TIF"));
            ShortInterleavedRaster inputRaster = (ShortInterleavedRaster) inputImage.getTile(0, 0);

            ColorSpace outCS = new ICC_ColorSpace(outProfile);
            ColorModel outCM = new ComponentColorModel(outCS, false, false,
                                                       Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
            ShortInterleavedRaster outputRaster =
                    (ShortInterleavedRaster) outCM.createCompatibleWritableRaster(inputImage.getWidth(),
                                                                                  inputImage.getHeight());
View Full Code Here


*/
class FastImageFactory {

    static RenderedImage systemColorSpaceImage(RenderedImage image) {
        ColorModel colors = image.getColorModel();
        ColorSpace space = colors.getColorSpace();
        if (space != null) {
            if (! space.equals(JAIContext.systemColorSpace)) {
                image = Functions.toColorSpace(
                    image, JAIContext.systemColorSpace, null
                );
            }
        }
View Full Code Here

                cm = colorModelRGBA32;
                break;
            }
        } else if (type == DataBuffer.TYPE_FLOAT &&
                   bands >= 1 && bands <= 4) {
            ColorSpace cs = bands <= 2 ?
                ColorSpace.getInstance(ColorSpace.CS_GRAY) :
                ColorSpace.getInstance(ColorSpace.CS_sRGB);
            boolean hasAlpha = bands % 2 == 0;
            cm = new FloatDoubleColorModel(cs, hasAlpha, false,
                                           hasAlpha ?
View Full Code Here

    private BufferedImage getGrayScale(BufferedImage bi) {
        // the following code is by David Ekholm from the GrayscaleFilter
        final Graphics2D g = bi.createGraphics();
        final RenderingHints rhs = g.getRenderingHints();

        final ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        final ColorConvertOp theOp = new ColorConvertOp(cs, rhs);

        final BufferedImage dstImg = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType());
        theOp.filter(bi, dstImg);
View Full Code Here

            }
        }
        closeStream(stream);

        // Set the ColorModel.
        ColorSpace cs = ColorSpace.getInstance(colorSpaceIndex);
        int dtSize = DataBuffer.getDataTypeSize(DataBuffer.TYPE_BYTE);
        int[] bits = new int[numBands];
        for(int i = 0; i < numBands; i++) {
            bits[i] = dtSize;
        }
View Full Code Here

            }
        }
        endResponse(stream);

        // Cache some values which will be used repetitively.
        ColorSpace cs = colorModel.getColorSpace();
        if(cs.isCS_sRGB()) {
            colorSpaceType = CS_NIFRGB;
        } else if(cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY))) {
            colorSpaceType = CS_MONOCHROME;
        } else {
            colorSpaceType = CS_PHOTOYCC;
        }
        hasAlpha = colorModel.hasAlpha();
View Full Code Here

        // Cache the ColorModels.
        srcParam = new ImageParameters(source.getColorModel(),
               source.getSampleModel());
  dstParam = new ImageParameters(colorModel, sampleModel);

        ColorSpace srcColorSpace = srcParam.getColorModel().getColorSpace();
        ColorSpace dstColorSpace = dstParam.getColorModel().getColorSpace();

  // for each case, define the case number; create tempParam
  // and/or ColorConvertOp if necessary
        if (srcColorSpace instanceof ColorSpaceJAI &&
            dstColorSpace instanceof ColorSpaceJAI) {
View Full Code Here

                colorConvertOp.filter(s, d);
            }
        } else {
            //For the floating point data types, convert via CIEXYZ color space.
            //Do it pixel-by-pixel (slow!).
            ColorSpace srcColorSpace = srcParam.getColorModel().getColorSpace();
            ColorSpace dstColorSpace = dstParam.getColorModel().getColorSpace();
      boolean srcFloat = srcParam.isFloat();
      float srcMinValue = srcParam.getMinValue();
      float srcRange = srcParam.getRange();

      boolean dstFloat = dstParam.isFloat();
      float dstMinValue = dstParam.getMinValue();
      float dstRange = dstParam.getRange();

            int rectYMax = destRect.y + destRect.height;
            int rectXMax = destRect.x + destRect.width;
            int numComponents = srcColorSpace.getNumComponents();
            float[] srcPixel = new float[numComponents];
            float[] xyzPixel;
            float[] dstPixel;
            for (int y = destRect.y; y < rectYMax; y++) {
                for (int x = destRect.x; x < rectXMax; x++) {
                    srcPixel = src.getPixel(x, y, srcPixel);
                    if (!srcFloat) {
                        // Normalize the source samples.
                        for (int i = 0; i < numComponents; i++) {
                            srcPixel[i] = (srcPixel[i] - srcMinValue)/srcRange;
                        }
                    }

                    // Convert src to dst via CIEXYZ.
                    xyzPixel = srcColorSpace.toCIEXYZ(srcPixel);
                    dstPixel = dstColorSpace.fromCIEXYZ(xyzPixel);

                    if (!dstFloat) {
                        // Scale the destination samples.
                        for (int i = 0; i < numComponents; i++) {
                            dstPixel[i] = (dstPixel[i]*dstRange + dstMinValue);
View Full Code Here

    public CompositeContext createContext(ColorModel srcCM,
                                          ColorModel dstCM,
                                          RenderingHints hints) {
        if (false) {
            ColorSpace srcCS = srcCM.getColorSpace();
            ColorSpace dstCS = dstCM.getColorSpace();
            System.out.println("srcCS: " + srcCS);
            System.out.println("dstCS: " + dstCS);
            System.out.println
                ("lRGB: " + ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB));
            System.out.println
View Full Code Here

        // SrcOver.  Otherwise things break...
        Composite c = g2d.getComposite();
        if (!SVGComposite.OVER.equals(c))
            return false;
       
        ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d);
        if ((g2dCS == null) ||
            (g2dCS != ColorSpace.getInstance(ColorSpace.CS_sRGB))){
            // Only draw directly into sRGB destinations...
            return false;
        }
View Full Code Here

TOP

Related Classes of java.awt.color.ColorSpace

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.