Example usage for java.awt.image ComponentColorModel ComponentColorModel

List of usage examples for java.awt.image ComponentColorModel ComponentColorModel

Introduction

In this page you can find the example usage for java.awt.image ComponentColorModel ComponentColorModel.

Prototype

public ComponentColorModel(ColorSpace colorSpace, int[] bits, boolean hasAlpha, boolean isAlphaPremultiplied,
        int transparency, int transferType) 

Source Link

Document

Constructs a ComponentColorModel from the specified parameters.

Usage

From source file:ComponentTest.java

public static void main(String[] args) {
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel cm = new ComponentColorModel(cs, new int[] { 5, 6, 5 }, false, false, Transparency.OPAQUE,
            DataBuffer.TYPE_BYTE);

    Color fifty = new Color(cs, new float[] { 1.0f, 1.0f, 1.0f }, 0);
    float[] components = fifty.getComponents(null);
    System.out.print("Original normalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(components[i] + " ");
    System.out.println();//from   w  w w. j ava2  s.com
    int[] unnormalized = cm.getUnnormalizedComponents(components, 0, null, 0);
    System.out.print("Original unnormalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(unnormalized[i] + " ");
    System.out.println();
    Object pixel = cm.getDataElements(unnormalized, 0, (Object) null);
    System.out.print("Pixel samples: ");
    byte[] pixelBytes = (byte[]) pixel;
    for (int i = 0; i < 3; i++)
        System.out.print(pixelBytes[i] + " ");
    System.out.println();

    unnormalized = cm.getComponents(pixel, null, 0);
    System.out.print("Derived unnormalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(unnormalized[i] + " ");
    System.out.println();
    components = cm.getNormalizedComponents(unnormalized, 0, null, 0);
    System.out.print("Derived normalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(components[i] + " ");
    System.out.println();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel cm = new ComponentColorModel(cs, new int[] { 5, 6, 5 }, false, false, Transparency.OPAQUE,
            DataBuffer.TYPE_BYTE);

    Color fifty = new Color(cs, new float[] { 1.0f, 1.0f, 1.0f }, 0);
    float[] components = fifty.getComponents(null);
    System.out.print("Original normalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(components[i] + " ");
    System.out.println();/*w w w.jav a 2 s  .c o  m*/
    int[] unnormalized = cm.getUnnormalizedComponents(components, 0, null, 0);
    System.out.print("Original unnormalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(unnormalized[i] + " ");
    System.out.println();

    Object pixel = cm.getDataElements(unnormalized, 0, (Object) null);
    System.out.print("Pixel samples: ");
    byte[] pixelBytes = (byte[]) pixel;
    for (int i = 0; i < 3; i++)
        System.out.print(pixelBytes[i] + " ");
    System.out.println();

    unnormalized = cm.getComponents(pixel, null, 0);
    System.out.print("Derived unnormalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(unnormalized[i] + " ");
    System.out.println();
    components = cm.getNormalizedComponents(unnormalized, 0, null, 0);
    System.out.print("Derived normalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(components[i] + " ");
}

From source file:org.apache.pdfbox.pdmodel.graphics.color.PDICCBased.java

/**
 * Create a Java color model for this colorspace.
 *
 * @param bpc The number of bits per component.
 *
 * @return A color model that can be used for Java AWT operations.
 *
 * @throws IOException If there is an error creating the color model.
 *///from   w  ww. j  a  v  a 2  s  .  c o  m
public ColorModel createColorModel(int bpc) throws IOException {

    int[] nbBits;
    int numOfComponents = getNumberOfComponents();
    switch (numOfComponents) {
    case 1:
        // DeviceGray
        nbBits = new int[] { bpc };
        break;
    case 3:
        // DeviceRGB
        nbBits = new int[] { bpc, bpc, bpc };
        break;
    case 4:
        // DeviceCMYK
        nbBits = new int[] { bpc, bpc, bpc, bpc };
        break;
    default:
        throw new IOException("Unknown colorspace number of components:" + numOfComponents);
    }
    ComponentColorModel componentColorModel = new ComponentColorModel(getJavaColorSpace(), nbBits, false, false,
            Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
    return componentColorModel;

}

From source file:org.deegree.ogcwebservices.wms.dataaccess.ID2PInterpolation.java

private void createImage() {

    ColorModel ccm;//from   w ww  . j a v  a  2  s .com

    if (use32Bits) {
        image = new BufferedImage(getMap.getWidth(), getMap.getHeight(), BufferedImage.TYPE_INT_ARGB);
    } else {
        ccm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), null, false, false,
                Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
        WritableRaster wr = ccm.createCompatibleWritableRaster(getMap.getWidth(), getMap.getHeight());
        image = new BufferedImage(ccm, wr, false, new Hashtable<Object, Object>());
    }
}

From source file:ImageComponentByReferenceTest.java

TiledImage() {
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    int[] nBits = { 8, 8, 8, 8 };
    int i, j, k, cc = 255;
    int[] bandOffset = new int[4];
    colorModel = new ComponentColorModel(cs, nBits, true, false, Transparency.OPAQUE, 0);
    // Create 9 tiles
    bandOffset[0] = 3;/*from  w ww  .j av  a 2s.  com*/
    bandOffset[1] = 2;
    bandOffset[2] = 1;
    bandOffset[3] = 0;
    for (i = 0; i < 3; i++) {
        for (j = 0; j < 3; j++) {
            tile[i][j] = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, 8, 8, 32, 4, bandOffset, null);
        }
    }

    // tile {-2, -1}
    byte[] byteData = ((DataBufferByte) tile[0][0].getDataBuffer()).getData();
    for (i = 4, k = 8 * 4 * 4 + 4 * 4; i < 8; i++, k += 16) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) cc;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
    }

    // tile {-1, -1}
    byteData = ((DataBufferByte) tile[1][0].getDataBuffer()).getData();
    for (i = 4, k = 8 * 4 * 4; i < 8; i++) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) cc;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
    }

    // tile {1, -1}
    byteData = ((DataBufferByte) tile[2][0].getDataBuffer()).getData();
    for (i = 4, k = 8 * 4 * 4; i < 8; i++, k += 16) {
        for (j = 0; j < 4; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
    }

    // tile {-2, 0}
    byteData = ((DataBufferByte) tile[0][1].getDataBuffer()).getData();
    for (i = 0, k = 16; i < 4; i++, k += 16) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) cc;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
    }
    for (i = 4, k = 8 * 4 * 4 + 16; i < 8; i++, k += 16) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) 0;
        }
    }
    // tile {-1, 0}
    byteData = ((DataBufferByte) tile[1][1].getDataBuffer()).getData();
    for (i = 0, k = 0; i < 4; i++) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) cc;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
    }
    for (i = 0, k = 8 * 4 * 4; i < 4; i++) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) 0;
        }

        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) cc;
        }

    }

    // tile {0, 0}
    byteData = ((DataBufferByte) tile[2][1].getDataBuffer()).getData();
    for (i = 0, k = 0; i < 4; i++, k += 16) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
    }
    for (i = 4, k = 8 * 4 * 4; i < 8; i++, k += 16) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) cc;
        }
    }

    // tile {-2, 1}
    byteData = ((DataBufferByte) tile[0][2].getDataBuffer()).getData();
    for (i = 4, k = 16; i < 8; i++, k += 16) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) 0;
        }
    }

    // tile {-1, 1}
    byteData = ((DataBufferByte) tile[1][2].getDataBuffer()).getData();
    for (i = 0, k = 0; i < 8; i++) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) 0;
        }
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) cc;
        }
    }

    // tile {0, 1}
    byteData = ((DataBufferByte) tile[2][2].getDataBuffer()).getData();
    for (i = 4, k = 0; i < 8; i++, k += 16) {
        for (j = 4; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) cc;
        }
    }

    bigTile = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, 16, 16, 64, 4, bandOffset, null);
    ;
    byteData = ((DataBufferByte) bigTile.getDataBuffer()).getData();
    for (i = 0, k = 0; i < 8; i++) {
        for (j = 0; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) cc;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
        for (; j < 16; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) 0;
            byteData[k + 3] = (byte) cc;
        }
    }
    for (; i < 16; i++) {
        for (j = 0; j < 8; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) 0;
        }
        for (; j < 16; j++, k += 4) {
            byteData[k] = (byte) 0;
            byteData[k + 1] = (byte) 0;
            byteData[k + 2] = (byte) cc;
            byteData[k + 3] = (byte) cc;
        }
    }
    checkBoard = new BufferedImage(colorModel, bigTile, false, null);
}

From source file:TrackerPanel.java

private void drawUserDepths(Graphics2D g2d) {
    // define an 8-bit RGB channel color model
    ColorModel colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
            new int[] { 8, 8, 8 }, false, false, ComponentColorModel.OPAQUE, DataBuffer.TYPE_BYTE);

    // fill the raster with the depth image bytes
    DataBufferByte dataBuffer = new DataBufferByte(imgbytes, imWidth * imHeight * 3);

    WritableRaster raster = Raster.createInterleavedRaster(dataBuffer, imWidth, imHeight, imWidth * 3, 3,
            new int[] { 0, 1, 2 }, null);

    // combine color model and raster to create a BufferedImage
    BufferedImage image = new BufferedImage(colorModel, raster, false, null);

    g2d.drawImage(image, 0, 0, null);//w w w  .j  av a2  s . co  m
}

From source file:org.photovault.dcraw.RawImage.java

/**
 *     Get a 8 bit gamma corrected version of the image.
 * @param minWidth Minimum width for the image that will be rendered
 * @param minHeight Minimum height for the image that will be rendered
 * @param isLowQualityAcceptable If true, renderer may use optimizations that
 * trade off image quality for speed.//from   w  ww  .j  a  va 2 s.c  om
 * @return The corrected image
 */
public RenderableOp getCorrectedImage(int minWidth, int minHeight, boolean isLowQualityAcceptable) {

    int maxSubsample = 1;
    if (minWidth > 0 && minHeight > 0) {
        while (width >= minWidth * 2 * maxSubsample && height >= minHeight * 2 * maxSubsample) {
            maxSubsample *= 2;
        }
    }
    if (rawImage == null || maxSubsample < subsample) {
        // dcraw.setHalfSize( isHalfSizeEnough );
        if (maxSubsample == 1 && subsample > 1) {
            // The image has been loaded with 1/2 resolution so reloading
            // cannot be avoided
            closeRaw();
        }
        subsample = maxSubsample;
        loadRawImage();
        correctedImage = null;
    }
    if (correctedImage == null) {
        RenderingHints nonCachedHints = new RenderingHints(JAI.KEY_TILE_CACHE, null);

        // TODO: Why setting color model as a rendering hint produces black image???
        RawConvDescriptor.register();
        ParameterBlock pb = new ParameterBlockJAI("RawConv");
        pb.setSource(wbAdjustedRawImage, 0);
        pb.set(white, 0);
        pb.set(black, 1);
        pb.set(highlightCompression, 2);
        rawConverter = JAI.createRenderable("RawConv", pb, nonCachedHints);
        rawConverter.setProperty("org.photovault.opname", "raw_toneadj_image");
        applyExposureSettings();

        // Convert from linear to gamma corrected
        createGammaLut();
        LookupTableJAI jailut = new LookupTableJAI(gammaLut);
        correctedImage = LookupDescriptor.createRenderable(rawConverter, jailut, null);
        correctedImage.setProperty("org.photovault.opname", "gamma_lut_image");
        // Store the color model of the image
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        cm = new ComponentColorModel(cs, new int[] { 8, 8, 8 }, false, false, Transparency.OPAQUE,
                DataBuffer.TYPE_BYTE);

    }
    return correctedImage;
}

From source file:org.geoserver.catalog.CoverageViewReader.java

private ColorModel getColorModelWithAlpha(int currentBandCount) {
    if (currentBandCount == 3) {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        int[] nBits = { 8, 8, 8, 8 };
        return new ComponentColorModel(cs, nBits, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
    } else if (currentBandCount == 1) {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        int[] nBits = { 8, 8 };
        return new ComponentColorModel(cs, nBits, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
    } else {/*  w w w  .  j ava  2 s .  co m*/
        throw new IllegalArgumentException("Cannot create a color model with alpha" + "support starting with "
                + currentBandCount + " bands");
    }
}

From source file:org.photovault.dcraw.RawImage.java

/**
 * Load the raw image using dcraw. No processing is yet done for the image,
 * however, the histogram & white point is calculated.
 *///from  w w w.ja va 2 s.  c  om
private void loadRawImage() {
    long startTime = System.currentTimeMillis();
    log.debug("begin:loadRawImage");
    if (lrd == null) {
        openRaw();
        log.debug("openRaw() " + (System.currentTimeMillis() - startTime));
        if (lrd == null) {
            throw new IllegalStateException("Called loadRawImage before opening file");
        }
        lr.libraw_unpack(lrd);
        log.debug("unpacked " + (System.currentTimeMillis() - startTime));
    }
    /*
     * Copy the unprocessed data to temporary array so that we can restore 
     * lrd to the state it had after unpack()
     */

    int oldFlags = lrd.progress_flags;
    int oldFilters = lrd.idata.filters;
    int rawImageSize = lrd.sizes.iwidth * lrd.sizes.iheight * 4;
    short rawWidth = lrd.sizes.width;
    short rawHeight = lrd.sizes.height;
    this.width = lrd.sizes.width;
    this.height = lrd.sizes.height;
    short[] rawData = lrd.image.getShortArray(0, rawImageSize);
    lr.libraw_dcraw_process(lrd);
    log.debug("processed " + (System.currentTimeMillis() - startTime));
    int procWidth = lrd.sizes.width;
    int procHeight = lrd.sizes.height;

    int postSubsample = (lrd.output_params.half_size > 0) ? subsample / 2 : subsample;
    /*
     * Copy the raw image to Java raster, using box filter to subsample
     */
    int scaledW = procWidth / postSubsample;
    int scaledH = procHeight / postSubsample;
    short[] buf = new short[scaledW * scaledH * 3];
    int pos = 0;
    for (int row = 0; row < scaledH; row++) {
        for (int col = 0; col < scaledW; col++) {
            int rsum = 0;
            int gsum = 0;
            int bsum = 0;
            for (int or = row * postSubsample; or < (row + 1) * postSubsample; or++) {
                for (int oc = col * postSubsample; oc < (col + 1) * postSubsample; oc++) {
                    int r = lrd.image.getShort(8 * (oc + procWidth * or));
                    rsum += (r & 0xffff);
                    int g = lrd.image.getShort(8 * (oc + procWidth * or) + 2);
                    gsum += (g & 0xffff);
                    int b = lrd.image.getShort(8 * (oc + procWidth * or) + 4);
                    bsum += (b & 0xffff);
                }
            }
            buf[pos++] = (short) (rsum / (postSubsample * postSubsample));
            buf[pos++] = (short) (gsum / (postSubsample * postSubsample));
            buf[pos++] = (short) (bsum / (postSubsample * postSubsample));
        }
    }
    log.debug("subsampled " + (System.currentTimeMillis() - startTime));

    // Restore LibRaw state to what it was before dcraw_process
    lrd.image.write(0, rawData, 0, rawImageSize);
    lrd.progress_flags = oldFlags;
    lrd.sizes.width = rawWidth;
    lrd.sizes.height = rawHeight;
    lrd.idata.filters = oldFilters;
    rawData = null;

    // closeRaw();

    DataBuffer db = new DataBufferUShort(buf, buf.length);
    SampleModel sampleModel = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_USHORT, scaledW,
            scaledH, 3, 3 * scaledW, new int[] { 0, 1, 2 });
    WritableRaster r = Raster.createWritableRaster(sampleModel, db, new Point(0, 0));
    log.debug("raster created " + (System.currentTimeMillis() - startTime));

    if (this.chanMultipliers == null) {
        chanMultipliers = cameraMultipliers.clone();
        calcCTemp();
    }

    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
    ColorModel targetCM = new ComponentColorModel(cs, new int[] { 16, 16, 16 }, false, false,
            Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
    rawImage = new TiledImage(new BufferedImage(targetCM, r, true, null), 256, 256);
    rawImage.setProperty("org.photovault.opname", "dcraw_data");

    if (preRotation.getJaiTransposeType() != null) {
        rawImage = TransposeDescriptor.create(rawImage, preRotation.getJaiTransposeType(), null);
        rawImage.setProperty("org.photovault.opname", "orientation_adjustment");
    }

    final float[] DEFAULT_KERNEL_1D = { 0.25f, 0.5f, 0.25f };
    ParameterBlock pb = new ParameterBlock();
    KernelJAI kernel = new KernelJAI(DEFAULT_KERNEL_1D.length, DEFAULT_KERNEL_1D.length,
            DEFAULT_KERNEL_1D.length / 2, DEFAULT_KERNEL_1D.length / 2, DEFAULT_KERNEL_1D, DEFAULT_KERNEL_1D);
    pb.add(kernel);
    BorderExtender extender = BorderExtender.createInstance(BorderExtender.BORDER_COPY);
    RenderingHints hints = JAI.getDefaultInstance().getRenderingHints();
    if (hints == null) {
        hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, extender);
    } else {
        hints.put(JAI.KEY_BORDER_EXTENDER, extender);
    }

    RenderedOp filter = new RenderedOp("convolve", pb, hints);
    // javax.media.jai.operator.BoxFilterDescriptor.create( null, new Integer(2), new Integer(2), new Integer(0), new Integer(0), null );

    // Add the subsampling operation.
    pb = new ParameterBlock();
    pb.addSource(filter);
    pb.add(new Float(0.5F)).add(new Float(0.5F));
    pb.add(new Float(0.0F)).add(new Float(0.0F));
    pb.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
    RenderedOp downSampler = new RenderedOp("scale", pb, null);
    // downSampler = javax.media.jai.operator.BoxFilterDescriptor.create( null, new Integer(2), new Integer(2), new Integer(0), new Integer(0), null );

    RenderableOp rawImageRenderable = RenderableDescriptor.createRenderable(rawImage, downSampler, null, null,
            null, null, null);
    double colorCorrMat[][] = new double[][] { { colorCorr[0], 0.0, 0.0, 0.0 }, { 0.0, colorCorr[1], 0.0, 0.0 },
            { 0.0, 0.0, colorCorr[2], 0.0 } };

    RenderingHints nonCachedHints = new RenderingHints(JAI.KEY_TILE_CACHE, null);
    wbAdjustedRawImage = BandCombineDescriptor.createRenderable(rawImageRenderable, colorCorrMat,
            nonCachedHints);
    wbAdjustedRawImage.setProperty("org.photovault.opname", "wb_adjusted_image");

    //            reader.getImageMetadata( 0 );
    //            rawIsHalfSized = dcraw.ishalfSize();
    //
    //            createHistogram();
    //        } catch (FileNotFoundException ex) {
    //            ex.printStackTrace();
    //        } catch (IOException ex) {
    //            ex.printStackTrace();
    //        } catch (PhotovaultException ex) {
    //            ex.printStackTrace();
    //        }
    log.debug("image ready " + (System.currentTimeMillis() - startTime));

    if (autoExposeRequested) {
        doAutoExpose();
    }
    log.debug("exit: loadRawImage " + (System.currentTimeMillis() - startTime));

}

From source file:org.photovault.image.PhotovaultImage.java

/**
 Add saturation mapping into from of the image processing pipeline.
 @param src The image to which saturation correction is applied
 @return Saturation change operator./*w w w .ja v  a  2s  .  c  o  m*/
 */
protected RenderableOp getSaturated(RenderableOp src) {
    IHSColorSpace ihs = IHSColorSpace.getInstance();
    ColorModel srcCm = getCorrectedImageColorModel();
    int[] componentSizes = srcCm.getComponentSize();
    if (componentSizes.length != 3) {
        // This is not an RGB image
        // TODO: handle also images with alpha channel
        return null;
    }
    ColorModel ihsColorModel = new ComponentColorModel(ihs, componentSizes, false, false, Transparency.OPAQUE,
            srcCm.getTransferType());

    // Create a ParameterBlock for the conversion.
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(src);
    pb.add(ihsColorModel);
    // Do the conversion.
    RenderableOp ihsImage = JAI.createRenderable("colorconvert", pb);
    ihsImage.setProperty("org.photovault.opname", "color_corrected_ihs_image");

    //        saturatedIhsImage =
    //                MultiplyConstDescriptor.createRenderable( ihsImage, new double[] {1.0, 1.0, saturation}, null );
    LookupTableJAI jailut = createSaturationMappingLUT();
    saturatedIhsImage = LookupDescriptor.createRenderable(ihsImage, jailut, null);
    saturatedIhsImage.setProperty("org.photovault.opname", "saturated_ihs_image");
    pb = new ParameterBlock();
    pb.addSource(saturatedIhsImage);
    ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel srgbColorModel = new ComponentColorModel(sRGB, componentSizes, false, false, Transparency.OPAQUE,
            srcCm.getTransferType());
    pb.add(srgbColorModel); // RGB color model!        
    RenderableOp saturatedImage = JAI.createRenderable("colorconvert", pb);
    saturatedImage.setProperty("org.photovault.opname", "saturated_image");

    return saturatedImage;
}