Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.ImageLayout


     * @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);

        Interpolation interp = (Interpolation)args.getObjectParameter(4);

        RenderedImage source = args.getRenderedSource(0);

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

     * @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);
       
        RenderedImage source = args.getRenderedSource(0);


        if (!MediaLibAccessor.isMediaLibCompatible(args, layout) ||
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

            // band counts must match
            return null;
        }

        // Get ImageLayout from RenderingHints if any.
        ImageLayout layoutHint = RIFUtil.getImageLayoutHint(hints);

        // Calculate the final ImageLayout.
        ImageLayout layout =
            MlibOrderedDitherOpImage.layoutHelper(layoutHint,
                                                  source, colorMap);

        // Check for source and destination compatibility. The ColorModel
        // is suppressed in the second test because it will be an
        // IndexColorModel which would cause the test to fail.
        SampleModel destSM = layout.getSampleModel(null);
        if (!MediaLibAccessor.isMediaLibCompatible(args) ||
            (!MediaLibAccessor.isMediaLibCompatible(destSM, null) &&
             !ImageUtil.isBinary(destSM))) {
            return null;
        }
View Full Code Here

     * Renders a "Mosaic" operation node.
     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);

        // Return if not mediaLib-compatible.
        if(!MediaLibAccessor.isMediaLibCompatible(paramBlock, layout) ||
           !MediaLibAccessor.hasSameNumBands(paramBlock, layout)) {
            return null;
        }

        // Get sources.
        Vector sources = paramBlock.getSources();

        // Get target SampleModel.
        SampleModel targetSM = null;
        if(sources.size() > 0) {
            targetSM = ((RenderedImage)sources.get(0)).getSampleModel();
        } else if(layout != null &&
                  layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
            targetSM = layout.getSampleModel(null);
        }

        if(targetSM != null) {
            // Return if target data type is floating point. Other more
            // extensive type checking is done in MosaicOpImage constructor.
View Full Code Here

    }

    private static ImageLayout layoutHelper(Vector sources,
                                            ImageLayout il) {

        ImageLayout layout = (il == null) ? new ImageLayout() : (ImageLayout)il.clone();

        int numSources = sources.size();

        // dest data type is the maximum of transfertype of source image
        // utilizing the monotonicity of data types.

        // dest number of bands = sum of source bands
        int destNumBands = totalNumBands(sources);

        int destDataType = DataBuffer.TYPE_BYTE;  // initialize
        RenderedImage srci = (RenderedImage)sources.get(0);
        Rectangle destBounds = new Rectangle(srci.getMinX(),  srci.getMinY(),
                                             srci.getWidth(), srci.getHeight());                                            
        for ( int i = 0; i < numSources; i++ ) {
            srci = (RenderedImage)sources.get(i);
            destBounds = destBounds.intersection(new Rectangle(srci.getMinX(), srci.getMinY(),
                                                 srci.getWidth(), srci.getHeight()));

            int typei = srci.getSampleModel().getTransferType();

            // NOTE: this depends on JDK ordering
            destDataType = typei > destDataType ? typei : destDataType;
        }

        SampleModel sm = layout.getSampleModel((RenderedImage)sources.get(0));

        if ( sm.getNumBands() < destNumBands ) {
            int[] destOffsets = new int[destNumBands];

            for(int i=0; i < destNumBands; i++) {
                destOffsets[i] = i;
            }

            // determine the proper width and height to use
            int destTileWidth = sm.getWidth();
            int destTileHeight = sm.getHeight();
            if(layout.isValid(ImageLayout.TILE_WIDTH_MASK))
            {
                destTileWidth =
                    layout.getTileWidth((RenderedImage)sources.get(0));
            }
            if(layout.isValid(ImageLayout.TILE_HEIGHT_MASK))
            {
                destTileHeight =
                    layout.getTileHeight((RenderedImage)sources.get(0));
            }
           
            sm = RasterFactory.createComponentSampleModel(sm,
                                                          destDataType,
                                                          destTileWidth,
                                                          destTileHeight,
                                                          destNumBands);


            layout.setSampleModel(sm);
        }

        ColorModel cm = layout.getColorModel(null);

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

        return layout;
    }
View Full Code Here

        RenderedImage src = args.getRenderedSource(0);
        Integer datatype = (Integer)args.getObjectParameter(0);
        int type = datatype.intValue();

        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);

        // If there is no change return the source image directly.
        if(layout == null && type == src.getSampleModel().getDataType()) {
            return src;
        }

        // Create or clone the ImageLayout.
        if(layout == null) {
            layout = new ImageLayout(src);
        } else {
            layout = (ImageLayout)layout.clone();
        }

  boolean isDataTypeChange = false;

        // Get prospective destination SampleModel.
        SampleModel sampleModel = layout.getSampleModel(src);

        // Create a new SampleModel if the type is not as desired.
        if (sampleModel.getDataType() != type) {
            int tileWidth = layout.getTileWidth(src);
            int tileHeight = layout.getTileHeight(src);
            int numBands = src.getSampleModel().getNumBands();

            SampleModel csm =
                RasterFactory.createComponentSampleModel(sampleModel,
                                                         type,
                                                         tileWidth,
                                                         tileHeight,
                                                         numBands);

            layout.setSampleModel(csm);
      isDataTypeChange = true;
        }


        // Check ColorModel.
        ColorModel colorModel = layout.getColorModel(null);
        if(colorModel != null &&
           !JDKWorkarounds.areCompatibleDataModels(layout.getSampleModel(src),
                                                   colorModel)) {
            // Clear the mask bit if incompatible.
            layout.unsetValid(ImageLayout.COLOR_MODEL_MASK);
        }

        // Check whether anything but the ColorModel is changing.
        if (layout.getSampleModel(src) == src.getSampleModel() &&
            layout.getMinX(src) == src.getMinX() &&
            layout.getMinY(src) == src.getMinY() &&
            layout.getWidth(src) == src.getWidth() &&
            layout.getHeight(src) == src.getHeight() &&
            layout.getTileWidth(src) == src.getTileWidth() &&
            layout.getTileHeight(src) == src.getTileHeight() &&
            layout.getTileGridXOffset(src) == src.getTileGridXOffset() &&
            layout.getTileGridYOffset(src) == src.getTileGridYOffset()) {

            if(layout.getColorModel(src) == src.getColorModel()) {
                // Nothing changed: return the source directly.
                return src;
            } else {
                // Remove TileCache hint from RenderingHints if present.
                RenderingHints hints = renderHints;
View Full Code Here

     * @param paramBlock  The source image and the dilation kernel.
     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        // Get BorderExtender from renderHints if any.
        BorderExtender extender = RIFUtil.getBorderExtenderHint(renderHints);

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.