Package java.awt.image.renderable

Examples of java.awt.image.renderable.ParameterBlock


            cachedImage = null;
        }

        private RenderedOp createBlender(PlanarImage front) {
            // Overlay result on the original image
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(front);
            pb.addSource(back);
            pb.add(blendingMode);
            pb.add(new Double(invertedRegion ? -opacity : opacity));
            pb.add(mask);
            pb.add(colorSelectionMask);

            // we don't know what front might generate, specify the output format to be the same as the input
            RenderingHints formatHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, Functions.getImageLayout(back));
            RenderedOp blender = JAI.create("Blend", pb, formatHints);
            // blender.setProperty(JAIContext.PERSISTENT_CACHE_TAG, Boolean.TRUE);
View Full Code Here


                                || !rendering.getInputTransform().equals(lastTransform)
                                || (blender != null && blender.getParameters().get(3) != colorSelectionMask))) {

                            PlanarImage labImage = Functions.toColorSpace(back, new LCMS_ColorSpace(new LCMS.LABProfile()),
                                                              LCMSColorConvertDescriptor.RELATIVE_COLORIMETRIC, null);
                            ParameterBlock pb = new ParameterBlock();
                            pb.addSource(labImage);
                            pb.add(new int[]{1, 2});
                            RenderedOp abImage = JAI.create("bandselect", pb, null);

                            pb = new ParameterBlock();
                            pb.addSource(back);
                            pb.add(new double[][]{{ColorScience.Wr, ColorScience.Wg, ColorScience.Wb, 0}});
                            PlanarImage monochrome = JAI.create("BandCombine", pb, null);

                            RenderingHints layoutHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, Functions.getImageLayout(labImage));
                            // layoutHints.add(JAIContext.noCacheHint);
                            pb = new ParameterBlock();
                            pb.addSource(monochrome);
                            pb.addSource(abImage);
                            PlanarImage maskImage = JAI.create("BandMerge", pb, layoutHints);

                            colorSelectionMask = new RGBColorSelectionMaskOpImage(maskImage, getColorSelection(), null);

                            ParameterBlock maskPB;

//                            KernelJAI morph = new KernelJAI(3, 3, new float[]{1, 1, 1, 1, 1, 1, 1, 1, 1});
//
//                            maskPB = new ParameterBlock();
//                            maskPB.addSource(colorSelectionMask);
//                            maskPB.add(morph);
//                            colorSelectionMask = JAI.create("Erode", maskPB, null);
//
//                            maskPB = new ParameterBlock();
//                            maskPB.addSource(colorSelectionMask);
//                            maskPB.add(morph);
//                            colorSelectionMask = JAI.create("Dilate", maskPB, null);

                            RenderingHints extenderHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                                              BorderExtender.createInstance(BorderExtender.BORDER_COPY));
                            KernelJAI kernel = Functions.getGaussKernel(0.5 * scale);
                            maskPB = new ParameterBlock();
                            maskPB.addSource(colorSelectionMask);
                            maskPB.add(kernel);
                            colorSelectionMask = JAI.create("Convolve", maskPB, extenderHints);

                            lastColorSelection = colorSelection;
                        } else if (colorSelection == null || colorSelection.isAllSelected())
                            colorSelectionMask = null;
View Full Code Here

                            0, 0, JAIContext.TILE_WIDTH, JAIContext.TILE_HEIGHT,
                            tiffImage.getSampleModel(),
                            tiffImage.getColorModel()
                        )
                    );
                    final ParameterBlock pb = new ParameterBlock();
                    pb.addSource(tiffImage);
                    pb.add(tiffImage.getSampleModel().getDataType());
                    image = JAI.create("Format", pb, formatHints);
                    image.setProperty(JAIContext.PERSISTENT_CACHE_TAG, Boolean.TRUE);
                } else
                    image = tiffImage;
            }
View Full Code Here

        Rectangle bounds = new Rectangle(minX, minY, width, height);

        visibleRect = bounds.intersection(visibleRect);

        if (bounds.contains(visibleRect)) {
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add((float) visibleRect.x);
            pb.add((float) visibleRect.y);
            pb.add((float) visibleRect.width);
            pb.add((float) visibleRect.height);
            image = JAI.create("Crop", pb, JAIContext.noCacheHint);
        }
        Dimension previewSize = getSize();

        if ((visibleRect.width > previewSize.width) ||
            (visibleRect.height > previewSize.height)
        ) {
            float scale = Math.min(
                previewSize.width / (float) visibleRect.width,
                previewSize.height / (float) visibleRect.height);

            image = ConvolveDescriptor.create(
                image, Functions.getGaussKernel(.25 / scale), null
            );
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add(scale);
            pb.add(scale);
            image = JAI.create("Scale", pb, JAIContext.noCacheHint);
        }
        image =
            Functions.toColorSpace(image, JAIContext.systemColorSpace, null);
View Full Code Here

        int ko = kernel.getXOrigin();
        float kdata[] = kernel.getHorizontalKernelData();
        float qsFilterArray[] = new float[kdata.length - ko];
        System.arraycopy(kdata, ko, qsFilterArray, 0, qsFilterArray.length);

        ParameterBlock params = new ParameterBlock();
        params.addSource(src);
        params.add(ratio);
        params.add(ratio);
        params.add(qsFilterArray);
        params.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
        return JAI.create("FilteredSubsample", params,
                          new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                             BorderExtender.createInstance(BorderExtender.BORDER_COPY)));
    }
View Full Code Here

            }

            if (!transform.isIdentity()) {
                RenderingHints extenderHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                                  BorderExtender.createInstance(BorderExtender.BORDER_COPY));
                ParameterBlock params = new ParameterBlock();
                params.addSource(image);
                params.add(transform);
                params.add(Interpolation.getInstance(cheapScale ? Interpolation.INTERP_BILINEAR : Interpolation.INTERP_BICUBIC));
                // params.add(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
                xformedSourceImage = JAI.create("Affine", params, extenderHints);
            } else
                xformedSourceImage = image;
        }
View Full Code Here

        ImageOrientation orientation = metadata.getOrientation();
        if (orientation != null) {
            transposeAngle = orientation.getCorrection();
            if (transposeAngle != null) {
                ParameterBlock pb = new ParameterBlock();
                pb.addSource(sourceImage);
                pb.add(transposeAngle);
                RenderedOp transposed = JAI.create("Transpose", pb, null);
                transposed.setProperty(JAIContext.PERSISTENT_CACHE_TAG, Boolean.TRUE);
                // sourceImage = transposed;

                CachedImage cache = new CachedImage(new ImageLayout(transposed), JAIContext.fileCache);
View Full Code Here

            AffineTransform xform = AffineTransform.getScaleInstance(scaleX, scaleY);

            RenderingHints formatHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));

            Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
            ParameterBlock params = new ParameterBlock();
            params.addSource(image);
            params.add(xform);
            params.add(interp);
            // NOTE: we cache this for the screen
            return JAI.create("Affine", params, formatHints);
        }
        return image;
    }
View Full Code Here

        Rectangle bounds = new Rectangle(image.getMinX(), image.getMinY(), image.getWidth(), image.getHeight());

        visibleRect = bounds.intersection(visibleRect);

        if (bounds.contains(visibleRect)) {
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add((float) visibleRect.x);
            pb.add((float) visibleRect.y);
            pb.add((float) visibleRect.width);
            pb.add((float) visibleRect.height);
            image = JAI.create("Crop", pb, JAIContext.noCacheHint);
        }

        Dimension previewSize = getSize();

        float scale = 1;
        if (visibleRect.width > previewSize.width || visibleRect.height > previewSize.height) {
            scale = Math.min(previewSize.width / (float) visibleRect.width, previewSize.height / (float) visibleRect.height);

            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add(scale);
            pb.add(scale);
            image = JAI.create("Scale", pb, JAIContext.noCacheHint);
        }

        // avoid keeping references to the input image
        if (image instanceof RenderedOp) {
            RenderedOp ropImage = (RenderedOp) image;

            SampleModel sm = ropImage.getSampleModel().createCompatibleSampleModel(image.getWidth(), image.getHeight());

            WritableRaster wr = Raster.createWritableRaster(sm, new Point(ropImage.getMinX(), ropImage.getMinY()));
            ropImage.copyData(wr);
            image = new BufferedImage(ropImage.getColorModel(), wr.createWritableTranslatedChild(0, 0), false, null);
            ropImage.dispose();
        }

        /* image = Functions.toColorSpace(image, JAIContext.sRGBColorSpace, null);

        if (((PlanarImage) image).getSampleModel().getDataType() == DataBuffer.TYPE_USHORT)
            image = Functions.fromUShortToByte(image, null); */

        if (!colorMode && image.getColorModel().getNumColorComponents() == 3) {
            ICC_Profile profile = ((ICC_ColorSpace) (image.getColorModel().getColorSpace())).getProfile();

            if (!(profile instanceof ICC_ProfileRGB)) {
                image = Functions.toColorSpace(image, JAIContext.sRGBColorSpace, null);
                profile = ((ICC_ColorSpace) (image.getColorModel().getColorSpace())).getProfile();
            }

            ICC_ProfileRGB rgb_profile = (ICC_ProfileRGB) profile;

            ColorScience.ICC_ProfileParameters pp = new ColorScience.ICC_ProfileParameters(rgb_profile);

            double[][] transform = {
                {pp.W[0], pp.W[1], pp.W[2], 0}
            };

            ParameterBlock pb = new ParameterBlock();
            pb.addSource(image);
            pb.add(transform);
            image = JAI.create("BandCombine", pb, JAIContext.noCacheHint); // Desaturate, single banded
        }

        return image;
    }
View Full Code Here

        }
        for (int i = colors[steps]; i < 256; i++) {
            lut[0][i] = lut[1][i] = lut[2][i] = (byte) colors[steps];
        }

        ParameterBlock pb = new ParameterBlock();
        pb.addSource(image);
        pb.add(new LookupTableJAI(lut));

        return JAI.create("lookup", pb, JAIContext.noCacheHint);
    }
View Full Code Here

TOP

Related Classes of java.awt.image.renderable.ParameterBlock

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.