Package javax.media.jai

Examples of javax.media.jai.ImageLayout


     * @param args  The source images.
     * @param hints  May contain rendering hints and destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints hints) {
        ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
       

        if (!MediaLibAccessor.isMediaLibCompatible(args, layout) ||
            !MediaLibAccessor.hasSameNumBands(args, layout)) {
            return null;
        }

        /* Check whether dest has data type of float or double. */
        if (layout != null) {
            SampleModel sm = layout.getSampleModel(null);

            if (sm != null) {
                int dtype = sm.getDataType();
                if (dtype == DataBuffer.TYPE_FLOAT ||
                    dtype == DataBuffer.TYPE_DOUBLE) {
View Full Code Here


     * @param hints  May contain rendering hints and destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints hints) {
        // Get ImageLayout and TileCache from RenderingHints.
        ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
       

        if (!MediaLibAccessor.isMediaLibCompatible(args, layout)) {
            return null;
        }
View Full Code Here

     * @param hints  May contain rendering hints and destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints hints) {
        /* Get ImageLayout and TileCache from RenderingHints. */
        ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
       

        if (!MediaLibAccessor.isMediaLibCompatible(args, layout) ||
            !MediaLibAccessor.hasSameNumBands(args, layout)) {
            return null;
View Full Code Here

     * @param hints  May contain rendering hints and destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints hints) {
        /* Get ImageLayout and TileCache from RenderingHints. */
        ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
       

        if (!MediaLibAccessor.isMediaLibCompatible(args, layout) ||
            !MediaLibAccessor.hasSameNumBands(args, layout)) {
            return null;
View Full Code Here

    public static PlanarImage generalColorConvert(PlanarImage src) {
        ColorSpace sRGBColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        ColorModel sRGBColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, sRGBColorSpace,
                                                                            false, false, Transparency.OPAQUE);
        ImageLayout rgbImageLayout = new ImageLayout();
        rgbImageLayout.setSampleModel(sRGBColorModel.createCompatibleSampleModel(src.getWidth(), src.getHeight()));
        RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
        rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        ParameterBlockJAI pb = new ParameterBlockJAI("colorconvert");
        pb.addSource(src);
        pb.setParameter("colormodel", sRGBColorModel);
View Full Code Here

        if (srcColorSpace instanceof ICC_ColorSpace) {
            // -- Convert CMYK to RGB
            ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
                                                                               false, true, Transparency.OPAQUE);
            ImageLayout rgbImageLayout = new ImageLayout();
            rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(src.getWidth(), src.getHeight()));
            RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
            rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            ParameterBlockJAI pb = new ParameterBlockJAI("colorconvert");
            pb.addSource(src);
            pb.setParameter("colormodel", rgbColorModel);

            return JAI.create("colorconvert", pb, rgbHints);
        } else {

            // get user defined color from ColorProfile data
            ColorSpace cmykColorSpace = CMMColorSpace.getInstance(src.getColorModel().getColorSpace().getType());

            ColorModel cmykColorModel = RasterFactory.createComponentColorModel(src.getSampleModel().getDataType(),
                                                                                cmykColorSpace, false, true,
                                                                                Transparency.OPAQUE);
            // replace ColorSpace by format convertor with CMYK ColorSpace
            ImageLayout cmykImageLayout = new ImageLayout();
            cmykImageLayout.setColorModel(cmykColorModel);
            RenderingHints cmykHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, cmykImageLayout);
            cmykHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            ParameterBlockJAI pb = new ParameterBlockJAI("format");
            pb.addSource(src);
            pb.setParameter("datatype", src.getSampleModel().getDataType());
            PlanarImage op = JAI.create("format", pb, cmykHints);

            // invert CMYK pixel value
            pb = new ParameterBlockJAI("invert");
            pb.addSource(src);
            op = JAI.create("invert", pb, cmykHints);

            // -- Convert CMYK to RGB
            ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
                                                                               false, true, Transparency.OPAQUE);
            ImageLayout rgbImageLayout = new ImageLayout();
            rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(op.getWidth(), op.getHeight()));
            RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
            rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            pb = new ParameterBlockJAI("colorconvert");
            pb.addSource(op);
            pb.setParameter("colormodel", rgbColorModel);
View Full Code Here

            ParameterBlock pb = new ParameterBlock();
            int[] bitsRGB = { 8, 8, 8 };
            ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            ColorModel cmRGB = new ComponentColorModel(sRGB, bitsRGB, false, false, Transparency.OPAQUE,
                                                       DataBuffer.TYPE_BYTE);
            ImageLayout il = new ImageLayout();

            il.setColorModel(cmRGB);

            RenderingHints rh = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);

            il.setSampleModel(cmRGB.createCompatibleSampleModel(src.getTileWidth(), src.getTileHeight()));
            pb = new ParameterBlock();
            pb.addSource(src);
            src = JAI.create("format", pb, rh);
        }
View Full Code Here

     * java.awt.RenderingHints)
     */
    @SuppressWarnings("deprecation")
    @Override
    public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) {
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);

        RenderedImage source = paramBlock.getRenderedSource(0);
        double scaleX = paramBlock.getDoubleParameter(0);
        double scaleY = paramBlock.getDoubleParameter(1);

View Full Code Here

    }
  }

  private static ImageLayout layoutHelper(RenderedImage source,
      double scaleX, double scaleY, ImageLayout il) {
    ImageLayout layout = (il == null) ? new ImageLayout()
        : (ImageLayout) il.clone();

    if (scaleX <= 0.0 || scaleY <= 0.0) {
      throw new IllegalArgumentException("Illegal scaleX or scaleY value");
    }

    int dWidth = (int) (source.getWidth() * scaleX);
    if (dWidth <= 0) {
      dWidth = 1;
    }
    int dHeight = (int) (source.getHeight() * scaleY);
    if (dHeight <= 0) {
      dHeight = 1;
    }

    layout.setMinX((int) Math.floor(source.getMinX() * scaleX));
    layout.setMinY((int) Math.floor(source.getMinY() * scaleY));
    layout.setWidth(dWidth);
    layout.setHeight(dHeight);

    return layout;
  }
View Full Code Here

                          dataType, tileWidth, tileHeight, numBands);
        } else {
            sampleModel = RasterFactory.createPixelInterleavedSampleModel(
                                  dataType, tileWidth, tileHeight, numBands);
        }
        return new ImageLayout(minX, minY, width, height,
                               tileX, tileY, tileWidth, tileHeight,
                               sampleModel, createComponentColorModel());
    }
View Full Code Here

TOP

Related Classes of javax.media.jai.ImageLayout

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.