Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.ImageLayout


    // Force the SampleModel and ColorModel to be the same as for
    // the source image.
    private static ImageLayout layoutHelper(ImageLayout layout,
                                            SampleModel sm,
                                            ColorModel cm) {
        ImageLayout newLayout;
        if (layout != null) {
            newLayout = (ImageLayout)layout.clone();
        } else {
            newLayout = new ImageLayout();
        }

        newLayout.setSampleModel(sm);
        newLayout.setColorModel(cm);

        return newLayout;
    }
View Full Code Here


                                Map config,
                                ImageLayout layout,
                                int shiftX,
                                int shiftY) {
        super(vectorize(source),
              layout == null ? new ImageLayout() : (ImageLayout)layout.clone(),
              config,
              false);

        // Calculate the four translation factors.
        xTrans =
View Full Code Here

     * @param renderHints  Optionally contains destination image layout.    
     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        return new XorOpImage(paramBlock.getRenderedSource(0),
            paramBlock.getRenderedSource(1),
                              renderHints,
View Full Code Here

     * @param hints  Optionally contains destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        return new MultiplyConstOpImage(args.getRenderedSource(0),
                                        renderHints,
                                        layout,
View Full Code Here

     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        RenderedImage source = paramBlock.getRenderedSource(0);

        ImageLayout layout = renderHints == null ? null :
            (ImageLayout)renderHints.get(JAI.KEY_IMAGE_LAYOUT);

        ColorQuantizerType algorithm =
            (ColorQuantizerType)paramBlock.getObjectParameter(0);
        int maxColorNum = paramBlock.getIntParameter(1);
View Full Code Here

                }
            }
        }

        // Create a new layout or clone the one passed in.
        ImageLayout mosaicLayout = layout == null ?
            new ImageLayout() : (ImageLayout)layout.clone();

        // Determine the mosaic bounds.
        Rectangle mosaicBounds = new Rectangle();
        if(mosaicLayout.isValid(ImageLayout.MIN_X_MASK |
                                ImageLayout.MIN_Y_MASK |
                                ImageLayout.WIDTH_MASK |
                                ImageLayout.HEIGHT_MASK)) {
            // Set the mosaic bounds to the value given in the layout.
            mosaicBounds.setBounds(mosaicLayout.getMinX(null),
                                   mosaicLayout.getMinY(null),
                                   mosaicLayout.getWidth(null),
                                   mosaicLayout.getHeight(null));
        } else if(numSources > 0) {
            // Set the mosaic bounds to the union of source bounds.
            mosaicBounds.setBounds(source0.getMinX(), source0.getMinY(),
                                   source0.getWidth(), source0.getHeight());
            for(int i = 1; i < numSources; i++) {
                RenderedImage source = (RenderedImage)sources.get(i);
                Rectangle sourceBounds =
                    new Rectangle(source.getMinX(), source.getMinY(),
                                  source.getWidth(), source.getHeight());
                mosaicBounds = mosaicBounds.union(sourceBounds);
            }
        }

        // Set the mosaic bounds in the layout.
        mosaicLayout.setMinX(mosaicBounds.x);
        mosaicLayout.setMinY(mosaicBounds.y);
        mosaicLayout.setWidth(mosaicBounds.width);
        mosaicLayout.setHeight(mosaicBounds.height);

        // Check the SampleModel if defined.
        if(mosaicLayout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
            // Get the SampleModel.
            SampleModel destSM = mosaicLayout.getSampleModel(null);

            // Unset SampleModel if differing band count or data type.
            boolean unsetSampleModel =
                destSM.getNumBands() != numBands ||
                destSM.getDataType() != dataType;

            // Unset SampleModel if differing sample size.
            for(int i = 0; !unsetSampleModel && i < numBands; i++) {
                if(destSM.getSampleSize(i) != sampleSize) {
                    unsetSampleModel = true;
                }
            }

            // Unset SampleModel if needed.
            if(unsetSampleModel) {
                mosaicLayout.unsetValid(ImageLayout.SAMPLE_MODEL_MASK);
            }
        }

        return mosaicLayout;
    }
View Full Code Here

     * @param paramBlock The scaling type.
     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       
       
        RenderedImage source = paramBlock.getRenderedSource(0);

        return new MagnitudePhaseOpImage(source, renderHints, layout,
View Full Code Here

        String[] names = ImageCodec.getDecoderNames(src);

        OperationRegistry registry =
            JAI.getDefaultInstance().getOperationRegistry();
        int bound = OpImage.OP_IO_BOUND;
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);

        if (renderHints != null) {
            RenderingHints.Key key;

            key = JAI.KEY_OPERATION_REGISTRY;
View Full Code Here

     * @param renderHints  Optionally contains destination image layout.    
     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        return new ComplexArithmeticOpImage(paramBlock.getRenderedSource(0),
                                            paramBlock.getRenderedSource(1),
                                            renderHints,
View Full Code Here

     */
    private static ImageLayout layoutHelper(ImageLayout layout,
                                            RenderedImage source,
                                            EnumeratedParameter dataNature) {
        // Create an ImageLayout or clone the one passed in.
        ImageLayout il = layout == null ?
            new ImageLayout() : (ImageLayout)layout.clone();

        // Force the origin to coincide with that of the source.
        il.setMinX(source.getMinX());
        il.setMinY(source.getMinY());

        // Recalculate the non-unity dimensions to be a positive power of 2.
        // XXX This calculation should not be effected if an implementation
        // of the FFT which supports arbitrary dimensions is used.
        int currentWidth = il.getWidth(source);
        int currentHeight = il.getHeight(source);
        int newWidth;
        int newHeight;
        if(currentWidth == 1 && currentHeight == 1) {
            newWidth = newHeight = 1;
        } else if(currentWidth == 1 && currentHeight > 1) {
            newWidth = 1;
            newHeight = MathJAI.nextPositivePowerOf2(currentHeight);
        } else if(currentWidth > 1 && currentHeight == 1) {
            newWidth = MathJAI.nextPositivePowerOf2(currentWidth);
            newHeight = 1;
        } else { // Neither dimension equal to unity.
            newWidth = MathJAI.nextPositivePowerOf2(currentWidth);
            newHeight = MathJAI.nextPositivePowerOf2(currentHeight);
        }
        il.setWidth(newWidth);
        il.setHeight(newHeight);

        // Set the complex flags for source and destination.
        boolean isComplexSource =
            !dataNature.equals(DFTDescriptor.REAL_TO_COMPLEX);
        boolean isComplexDest =
            !dataNature.equals(DFTDescriptor.COMPLEX_TO_REAL);

        // Initialize the SampleModel creation flag.
        boolean createNewSampleModel = false;

        // Determine the number of required bands.
        SampleModel srcSampleModel = source.getSampleModel();
        int requiredNumBands = srcSampleModel.getNumBands();
        if(isComplexSource && !isComplexDest) {
            requiredNumBands /= 2;
        } else if(!isComplexSource && isComplexDest) {
            requiredNumBands *= 2;
        }

        // Set the number of bands.
        SampleModel sm = il.getSampleModel(source);
        int numBands = sm.getNumBands();
        if(numBands != requiredNumBands) {
            numBands = requiredNumBands;
            createNewSampleModel = true;
        }

        // Force the image to contain floating point data.
        int dataType = sm.getTransferType();
        if(dataType != DataBuffer.TYPE_FLOAT &&
           dataType != DataBuffer.TYPE_DOUBLE) {
            dataType = DataBuffer.TYPE_FLOAT;
            createNewSampleModel = true;
        }

        // Create a new SampleModel for the destination if necessary.
        if(createNewSampleModel) {
            sm = RasterFactory.createComponentSampleModel(sm,
                                                          dataType,
                                                          newWidth,
                                                          newHeight,
                                                          numBands);
            il.setSampleModel(sm);

            // Clear the ColorModel mask if needed.
            ColorModel cm = il.getColorModel(null);
            if(cm != null &&
               !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
                // Clear the mask bit if incompatible.
                il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
            }
        }

        return il;
    }
View Full Code Here

TOP

Related Classes of com.lightcrafts.mediax.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.