Package java.awt.color

Examples of java.awt.color.ColorSpace


                int lcms_proofIntent = proofIntent.getValue() < 4 ? proofIntent.getValue() : LCMS.INTENT_RELATIVE_COLORIMETRIC;
                int lcms_flags = intent.getValue() == 4 || proofIntent.getValue() == 4
                                 ? LCMS.cmsFLAGS_BLACKPOINTCOMPENSATION
                                 : 0;

                ColorSpace sourceCS = source.getColorModel().getColorSpace();
                LCMS.Profile sourceProfile = sourceCS instanceof LCMS_ColorSpace
                                             ? ((LCMS_ColorSpace) sourceCS).getProfile()
                                             : new LCMS.Profile(((ICC_ColorSpace)sourceCS).getProfile());

                ColorSpace targetCS = targetColorModel.getColorSpace();
                LCMS.Profile targetProfile = targetCS instanceof LCMS_ColorSpace
                                             ? ((LCMS_ColorSpace) targetCS).getProfile()
                                             : new LCMS.Profile(((ICC_ColorSpace)targetCS).getProfile());

                LCMS.Profile proofProfile = proof != null ? new LCMS.Profile(proof) : null;

                int inType = mapLCMSType(sourceCS.getType(), source.getColorModel().getTransferType());
                int outType = mapLCMSType(targetCS.getType(), colorModel.getTransferType());

                transform = proofProfile != null
                            ? new LCMS.Transform(sourceProfile, inType, targetProfile, outType, proofProfile,
                                                 lcms_proofIntent, lcms_intent, lcms_flags)
                            : new LCMS.Transform(sourceProfile, inType, targetProfile, outType, lcms_intent, lcms_flags);
View Full Code Here


    }

    public static PlanarImage toUShortLinear(PlanarImage image, RenderingHints hints) {
        // int numComponents = image.getColorModel().getNumComponents();

        ColorSpace linearCS = /* numComponents == 1 ?
                              JAIContext.linearGrayColorSpace : */
                              JAIContext.linearColorSpace;

        if (image.getColorModel().getColorSpace().equals(linearCS)
            && image.getSampleModel().getDataType() == DataBuffer.TYPE_USHORT)
View Full Code Here

                    numExtraSamples = numBands - 1;
                }
            }

        } else { // colorModel is non-null but not an IndexColorModel
            ColorSpace colorSpace = colorModel.getColorSpace();

            switch(colorSpace.getType()) {
            case ColorSpace.TYPE_CMYK:
                imageType = TIFF_CMYK;
                break;
            case ColorSpace.TYPE_GRAY:
                imageType = TIFF_GRAY;
                break;
            case ColorSpace.TYPE_Lab:
                imageType = TIFF_CIELAB;
                break;
            case ColorSpace.TYPE_RGB:
                if(compression == COMP_JPEG_TTN2 &&
                   encodeParam.getJPEGCompressRGBToYCbCr()) {
                    imageType = TIFF_YCBCR;
                } else {
                    imageType = TIFF_RGB;
                }
                break;
            case ColorSpace.TYPE_YCbCr:
                imageType = TIFF_YCBCR;
                break;
            default:
                imageType = TIFF_GENERIC; // generic
                break;
            }

            if(imageType == TIFF_GENERIC) {
                numExtraSamples = numBands - 1;
            } else if(numBands > 1) {
                numExtraSamples = numBands - colorSpace.getNumComponents();
            }

            if(numExtraSamples == 1 && colorModel.hasAlpha()) {
                extraSampleType = colorModel.isAlphaPremultiplied() ?
                    EXTRA_SAMPLE_ASSOCIATED_ALPHA :
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.
                    synchronized (CMM.class) {
                        xyzPixel = srcColorSpace.toCIEXYZ(srcPixel);
                        dstPixel = dstColorSpace.fromCIEXYZ(xyzPixel);
                    }

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

        int tileWidth = width, tileHeight = height;
        Raster srcRaster =
           RasterFactory.createInterleavedRaster(dataType,
                                          tileWidth,tileHeight,bands,null);
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        int bits[] = {8,8,8};
        ComponentColorModel ccm =
           new ComponentColorModel(cs,bits,false,false,
                                   Transparency.OPAQUE,DataBuffer.TYPE_BYTE);
View Full Code Here

                               tileX, tileY, tileWidth, tileHeight,
                               sampleModel, createComponentColorModel());
    }

    public static ComponentColorModel createComponentColorModel() {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        int bits[] = {8, 8, 8};
        return new ComponentColorModel(cs, bits, false, false,
                                       Transparency.OPAQUE,
                                       DataBuffer.TYPE_BYTE);
    }
View Full Code Here

              boolean isAlphaPremultiplied,
              int transparency) {

  ComponentColorModel ccm = null;
        int RGBBits[] = null;
        ColorSpace cs = null;
        switch(numBands) {
        case 2: // gray+alpha
            cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
            break;
        case 4: // RGB+alpha
View Full Code Here

        if (colorMode) {
            colorModel = image.getColorModel();
            raster = Raster.createInterleavedRaster(data, bounds.width, bounds.height, 3 * bounds.width, 3, new int[]{0, 1, 2}, null);
        } else {
            raster = Raster.createInterleavedRaster(data, bounds.width, bounds.height, bounds.width, 1, new int[]{0}, null);
            ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
            colorModel = new ComponentColorModel(cs, new int[]{8}, false, true,
                                                 Transparency.OPAQUE,
                                                 DataBuffer.TYPE_BYTE);
        }

View Full Code Here

        return xform;
    }

    private 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

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.