Package java.awt.image

Examples of java.awt.image.SampleModel


                             LookupTableJAI table) {
        super(source, layout, config, true);

        this.table = table;

        SampleModel sm = source.getSampleModel()// source sample model

        if (sampleModel.getTransferType() != table.getDataType() ||
            sampleModel.getNumBands() !=
                table.getDestNumBands(sm.getNumBands())) {
            /*
             * The current SampleModel is not suitable for the supplied
             * source and lookup table. Create a suitable SampleModel
             * and ColorModel for the destination image.
             */
 
View Full Code Here


        Rectangle srcRect = mapDestRect(destRect, 0);

        int srcTag = MediaLibAccessor.findCompatibleTag(null, source);
        int dstTag = MediaLibAccessor.findCompatibleTag(null, dest);

        SampleModel sm = source.getSampleModel();
        if (sm.getNumBands() > 1) {
            int srcCopy = srcTag & MediaLibAccessor.COPY_MASK;
            int dstCopy = dstTag & MediaLibAccessor.COPY_MASK;

            int srcDtype = srcTag & MediaLibAccessor.DATATYPE_MASK;
            int dstDtype = dstTag & MediaLibAccessor.DATATYPE_MASK;
View Full Code Here

      return true;

        RenderedImage src1 = args.getRenderedSource(0);
        RenderedImage src2 = args.getRenderedSource(1);

        SampleModel s1sm = src1.getSampleModel();
        SampleModel s2sm = src2.getSampleModel();
        if (s1sm.getNumBands() != s2sm.getNumBands() ||
            s1sm.getTransferType() != s2sm.getTransferType()) {
            msg.append(getName() + " " +
                       JaiI18N.getString("CompositeDescriptor8"));
            return false;
        }

        /* Validate Parameters. */
  RenderedImage afa1 = (RenderedImage)args.getObjectParameter(0);
        if (src1.getMinX() != afa1.getMinX() ||
            src1.getMinY() != afa1.getMinY() ||
            src1.getWidth() != afa1.getWidth() ||
            src1.getHeight() != afa1.getHeight()) {
            msg.append(getName() + " " +
                       JaiI18N.getString("CompositeDescriptor12"));
            return false;
        }

        SampleModel a1sm = afa1.getSampleModel();
        if (s1sm.getTransferType() != a1sm.getTransferType()) {
            msg.append(getName() + " " +
                       JaiI18N.getString("CompositeDescriptor13"));
            return false;
        }

  RenderedImage afa2 = (RenderedImage)args.getObjectParameter(1);
        if (afa2 != null) {
            if (src2.getMinX() != afa2.getMinX() ||
                src2.getMinY() != afa2.getMinY() ||
                src2.getWidth() != afa2.getWidth() ||
                src2.getHeight() != afa2.getHeight()) {
                msg.append(getName() + " " +
                           JaiI18N.getString("CompositeDescriptor15"));
                return false;
            }
       
            SampleModel a2sm = afa2.getSampleModel();
            if (s2sm.getTransferType() != a2sm.getTransferType()) {
                msg.append(getName() + " " +
                           JaiI18N.getString("CompositeDescriptor16"));
                return false;
            }
        }
View Full Code Here

        if (srcs != null) {
           tagIDs = new int[srcs.length + 1];
        } else {
           tagIDs = new int[1];
  }
        SampleModel dstSampleModel = dst.getSampleModel();
        int dstDataType = dstSampleModel.getTransferType();

        int defaultDataType = dstDataType;
        boolean binaryDst = ImageUtil.isBinary(dstSampleModel);
        if (binaryDst) {
            defaultDataType = DataBuffer.TYPE_BYTE;
        } else if((dstDataType == DataBuffer.TYPE_BYTE) ||
            (dstDataType == DataBuffer.TYPE_USHORT) ||
            (dstDataType == DataBuffer.TYPE_SHORT)) {
            defaultDataType = DataBuffer.TYPE_INT;
        }

        // use highest precision datatype of all srcs & dst
        if (srcs != null) {
            int numSources = srcs.length;
            int i;
            for (i = 0; i < numSources; i++) {
                SampleModel srcSampleModel = srcs[i].getSampleModel();
                int srcDataType = srcSampleModel.getTransferType();
                if (!(binaryDst && ImageUtil.isBinary(srcSampleModel)) &&
                    srcDataType > defaultDataType) {
                    defaultDataType = srcDataType;
                }
            }
        }

        // Set the tag. For binary data at this point this should
        // equal DataBuffer.TYPE_BYTE | COPIED.
        int tagID = defaultDataType | COPIED;
        if (dstSampleModel instanceof ComponentSampleModel) {
            if (srcs != null) {
               int numSources = srcs.length;
               int i;
               for (i = 0; i < numSources; i++) {
                   SampleModel srcSampleModel = srcs[i].getSampleModel();
                   int srcDataType = srcSampleModel.getTransferType();
                   if (!(srcSampleModel instanceof ComponentSampleModel) ||
                       (srcDataType != dstDataType)) {
                       break;
                   }
               }
View Full Code Here

        ColorModel colorModel = im.getColorModel();
        if (colorModel instanceof IndexColorModel) {
            return new PNGEncodeParam.Palette();
        }

        SampleModel sampleModel = im.getSampleModel();
        int numBands = sampleModel.getNumBands();

        if (numBands == 1 || numBands == 2) {
            return new PNGEncodeParam.Gray();
        } else {
            return new PNGEncodeParam.RGB();
View Full Code Here

            !dataNature.equals(DFTDescriptor.REAL_TO_COMPLEX);
        boolean isComplexDest =
            !dataNature.equals(DFTDescriptor.COMPLEX_TO_REAL);

        // Get the number of source bands.
        SampleModel srcSampleModel = source.getSampleModel();
        int numSourceBands = srcSampleModel.getNumBands();

        // Check for mediaLib support of this source.
        if((isComplexSource && numSourceBands != 2) ||
           (!isComplexSource && numSourceBands != 1)) {
            // This should never occur due to checks in
            // 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;
        }
View Full Code Here

     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints hints) {
        // Get the source and its SampleModel.
  RenderedImage source = args.getRenderedSource(0);
        SampleModel sm = source.getSampleModel();

        // Check that the source is single-banded and mediaLib compatible.
        // Ignore the layout because if it doesn't specify a bilevel image
        // then MlibBinarizeOpImage will revise it.
        if (!MediaLibAccessor.isMediaLibCompatible(args) ||
            sm.getNumBands() > 1) {
            return null;
        }

        // Get the threshold value.
        double thresh = args.getDoubleParameter(0);

  // java set all 0's or 1's fast
  if ((thresh > 255|| thresh <=0) && sm.getDataType()== DataBuffer.TYPE_BYTE ||
      (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);
       
View Full Code Here

            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) {
                    return null;
                }
            }
View Full Code Here

        // resolved by Java2D as to whether the underlying DataBuffer
        // must be of one of the standard types.  Here we make the
        // assumption that it will be -- we can't check without
        // forcing an actual tile to be computed.
        //
        SampleModel sm = source.getSampleModel();
        if ((sm instanceof MultiPixelPackedSampleModel) &&
            (sm.getSampleSize(0) == 1) &&
            (sm.getDataType() == DataBuffer.TYPE_BYTE ||
             sm.getDataType() == DataBuffer.TYPE_USHORT ||
             sm.getDataType() == DataBuffer.TYPE_INT)) {
      
       int srcWidth = source.getWidth();
       int srcHeight= source.getHeight();
       float floatTol = .1F * Math.min(xScale/(srcWidth*xScale+1.0F), yScale/(srcHeight*yScale+1.0F));
       int invScale = (int) Math.round(1.0F/xScale);
View Full Code Here

        if ( raster == null ) {
            throw new IllegalArgumentException(JaiI18N.getString("Generic0"));
        }

        SampleModel sampleModel = raster.getSampleModel();

        if (sampleModel.getNumBands() != numBands) {
            throw new IllegalArgumentException(
                JaiI18N.getString("Histogram4"));
        }

        Rectangle bounds = raster.getBounds();
View Full Code Here

TOP

Related Classes of java.awt.image.SampleModel

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.