Package javax.media.jai

Examples of javax.media.jai.ImageLayout


    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {

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

        // Test for media lib compatibility
        if (!MediaLibAccessor.isMediaLibCompatible(paramBlock, layout) ||
            !MediaLibAccessor.hasSameNumBands(paramBlock, 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);
       
        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

    // Copied whole hog from ErrorDiffusionOpImage.
    static ImageLayout layoutHelper(ImageLayout layout,
                                    RenderedImage source,
                                    LookupTableJAI colormap) {
        // Create or clone the layout.
        ImageLayout il = layout == null ?
      new ImageLayout() : (ImageLayout)layout.clone();

        // Force the destination and source origins and dimensions to coincide.
        il.setMinX(source.getMinX());
        il.setMinY(source.getMinY());
        il.setWidth(source.getWidth());
        il.setHeight(source.getHeight());

        // Get the SampleModel.
        SampleModel sm = il.getSampleModel(source);

        // Ensure an appropriate SampleModel.
        if(colormap.getNumBands() == 1 &&
           colormap.getNumEntries() == 2 &&
           !ImageUtil.isBinary(il.getSampleModel(source))) {
            sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                 il.getTileWidth(source),
                                                 il.getTileHeight(source),
                                                 1);
            il.setSampleModel(sm);
        }

        // Make sure that this OpImage is single-banded.
        if (sm.getNumBands() != 1) {
            sm =
                RasterFactory.createComponentSampleModel(sm,
                                                         sm.getTransferType(),
                                                         sm.getWidth(),
                                                         sm.getHeight(),
                                                         1);
      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);
            }
        }

        // Set an IndexColorModel on the image if:
        // a. none is provided in the layout;
        // b. source, destination, and colormap have byte data type;
        // c. the colormap has 3 bands.
        if((layout == null || !il.isValid(ImageLayout.COLOR_MODEL_MASK)) &&
           source.getSampleModel().getDataType() == DataBuffer.TYPE_BYTE &&
           sm.getDataType() == DataBuffer.TYPE_BYTE &&
           colormap.getDataType() == DataBuffer.TYPE_BYTE &&
           colormap.getNumBands() == 3) {
            ColorModel cm = source.getColorModel();
            if(cm == null ||
               (cm != null && cm.getColorSpace().isCS_sRGB())) {
                int size = colormap.getNumEntries();
                byte[][] cmap = new byte[3][256];
                for(int i = 0; i < 3; i++) {
                    byte[] band = cmap[i];
                    byte[] data = colormap.getByteData(i);
                    int offset = colormap.getOffset(i);
                    int end = offset + size;
                    for(int j = 0; j < offset; j++) {
                        band[j] = (byte)0;
                    }
                    for(int j = offset; j < end; j++) {
                        band[j] = data[j - offset];
                    }
                    for(int j = end; j < 256; j++) {
                        band[j] = (byte)0xFF;
                    }
                }

                il.setColorModel(new IndexColorModel(8, 256,
                                                     cmap[0], cmap[1],
                                                     cmap[2]));
            }
        }
View Full Code Here

        if (!MediaLibAccessor.isMediaLibBinaryCompatible(args, null)) {
            return null;
        }

        // Get ImageLayout from RenderingHints.
        ImageLayout layout = RIFUtil.getImageLayoutHint(hints);

        // Verify that the destination is mediaLib-compatible and has
        // the same number of bands as the source.
        if ((layout != null &&
             layout.isValid(ImageLayout.SAMPLE_MODEL_MASK) &&
             !MediaLibAccessor.isMediaLibCompatible(
                  layout.getSampleModel(null),
                  layout.getColorModel(null))) ||
            !MediaLibAccessor.hasSameNumBands(args, layout)) {
            return null;
        }

        // Get BorderExtender from hints if any.
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);
       

        boolean isBinary = false;
        if (!MediaLibAccessor.isMediaLibCompatible(args, layout) ||
            !MediaLibAccessor.hasSameNumBands(args, layout)) {
View Full Code Here

            // MlibDFTRIF and MlibIDFTRIF.
            throw new RuntimeException(JaiI18N.getString("MlibDFTOpImage0"));
        }

        // 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);

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

        // Determine the number of required bands.
        int requiredNumBands = numSourceBands;
        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) {
            int[] bandOffsets = new int[numBands];
            // Force the band offsets to be monotonically increasing as
            // mediaLib expects the real part to be in band 0 and the
            // imaginary part in band 1.
            for(int b = 0; b < numBands; b++) {
                bandOffsets[b] = b;
            }

            int lineStride = newWidth*numBands;
            sm = RasterFactory.createPixelInterleavedSampleModel(dataType,
                                                                 newWidth,
                                                                 newHeight,
                                                                 numBands,
                                                                 lineStride,
                                                                 bandOffsets);
            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

      (thresh > Short.MAX_VALUE|| thresh <=0) && sm.getDataType()== DataBuffer.TYPE_SHORT||
      (thresh > Integer.MAX_VALUE|| thresh <=0) && sm.getDataType()== DataBuffer.TYPE_INT)
          return null;

        // Get ImageLayout from RenderingHints.
        ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
       
  return new MlibBinarizeOpImage(source,
               layout,
               hints,
               thresh);
View Full Code Here

     * @param args  The source image and the constants.
     * @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

     * @throws RemoteImagingException if a RemoteException is thrown
     *         during the RMI communication.
     */
    public ImageLayout getImageLayout() throws RemoteImagingException {

  ImageLayout layout = new ImageLayout();
  try {
      layout.setMinX(remoteImage.getMinX(id));
      layout.setMinY(remoteImage.getMinY(id));
      layout.setWidth(remoteImage.getWidth(id));
      layout.setHeight(remoteImage.getHeight(id));
      layout.setTileWidth(remoteImage.getTileWidth(id));
      layout.setTileHeight(remoteImage.getTileHeight(id));
      layout.setTileGridXOffset(remoteImage.getTileGridXOffset(id));
      layout.setTileGridYOffset(remoteImage.getTileGridYOffset(id));

      SerializableState smState = remoteImage.getSampleModel(id);
      layout.setSampleModel((SampleModel)(smState.getObject()));
      SerializableState cmState = remoteImage.getColorModel(id);
      layout.setColorModel((ColorModel)(cmState.getObject()));
            return layout;
  } catch (RemoteException re) {
            String message = JaiI18N.getString("RMIServerProxy14");
            listener.errorOccurred(message,
                                   new RemoteImagingException(message, re),
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.