Examples of SampleModel


Examples of java.awt.image.SampleModel

    public WritableRaster copyData(WritableRaster raster) {
        Rectangle region;               // the region to be copied
        if (raster == null) {           // copy the entire image
            region = getBounds();

            SampleModel sm = getSampleModel();
            if(sm.getWidth() != region.width ||
               sm.getHeight() != region.height) {
                sm = sm.createCompatibleSampleModel(region.width,
                                                    region.height);
            }
            raster = createWritableRaster(sm, region.getLocation());
        } else {
            region = raster.getBounds().intersection(getBounds());
View Full Code Here

Examples of java.awt.image.SampleModel

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

        // Create a WritableRaster of the desired size
        SampleModel destSM = getSampleModel();
        if(destSM.getWidth() != region.width ||
           destSM.getHeight() != region.height) {
            destSM = destSM.createCompatibleSampleModel(region.width,
                                                        region.height);
        }

        // Translate it
        WritableRaster dest = createWritableRaster(destSM,
View Full Code Here

Examples of java.awt.image.SampleModel

        } else {
            rect = getBounds().intersection(rect);
        }


        SampleModel sm =
            sampleModel.getWidth() != rect.width ||
            sampleModel.getHeight() != rect.height ?
            sampleModel.createCompatibleSampleModel(rect.width,
                                                    rect.height) :
            sampleModel;
View Full Code Here

Examples of java.awt.image.SampleModel

        return Object.class;
    }

    public boolean canEncodeImage(RenderedImage im,
                                  ImageEncodeParam param) {
        SampleModel sampleModel = im.getSampleModel();
        int dataType = sampleModel.getTransferType();
        if (dataType != DataBuffer.TYPE_BYTE &&
            !CodecUtils.isPackedByteImage(im)) {
            return false;
        }
View Full Code Here

Examples of java.awt.image.SampleModel

     * <code>FloatDoubleColorModel</code>.
     *
     * @param raster a <code>Raster</code>to be checked for compatibility.
     */
    public boolean isCompatibleRaster(Raster raster) {
        SampleModel sm = raster.getSampleModel();
        return isCompatibleSampleModel(sm);
    }
View Full Code Here

Examples of java.awt.image.SampleModel

     *
     * @see java.awt.image.WritableRaster
     * @see java.awt.image.SampleModel
     */
    public WritableRaster createCompatibleWritableRaster(int w, int h) {
        SampleModel sm = createCompatibleSampleModel(w, h);
        return RasterFactory.createWritableRaster(sm, new Point(0, 0));
    }
View Full Code Here

Examples of java.awt.image.SampleModel

    public void encode(RenderedImage im) throws IOException {
        //
        // Check data type and band count compatibility.
        // This implementation handles only 1 and 3 band source images.
        //
        SampleModel sampleModel = im.getSampleModel();
        ColorModel  colorModel  = im.getColorModel();

        // Must be a 1 or 3 band BYTE image
        int numBands  = colorModel.getNumColorComponents();
        int transType = sampleModel.getTransferType();
        if (((transType != DataBuffer.TYPE_BYTE) &&
             !CodecUtils.isPackedByteImage(im)) ||
            ((numBands != 1) && (numBands != 3) )) {
            throw new RuntimeException(JaiI18N.getString("JPEGImageEncoder0"));
        }

        // Must be GRAY or RGB
        int cspaceType = colorModel.getColorSpace().getType();
        if (cspaceType != ColorSpace.TYPE_GRAY &&
            cspaceType != ColorSpace.TYPE_RGB) {
            throw new RuntimeException(JaiI18N.getString("JPEGImageEncoder1"));
        }

        //
        // Create a BufferedImage to be encoded.
        // The JPEG interfaces really need a whole image.
        //
        BufferedImage bi;
        if(im instanceof BufferedImage) {
            bi = (BufferedImage)im;
        } else {
            //
            // Get a contiguous raster. Jpeg compression can't work
            // on tiled data in most cases.
            // Also need to be sure that the raster doesn't have a
            // non-zero origin, since BufferedImage won't accept that.
            // (Bug ID 4253990)
            //

            //Fix 4694162: JPEGImageEncoder throws ClassCastException
            // Obtain the contiguous Raster.
            Raster ras;
            if(im.getNumXTiles() == 1 && im.getNumYTiles() == 1) {
                // Image is not tiled so just get a reference to the tile.
                ras = im.getTile(im.getMinTileX(), im.getMinTileY());
            } else {
                // Image is tiled so need to get a contiguous raster.

                // Create an interleaved raster for copying for 8-bit case.
                // This ensures that for RGB data the band offsets are {0,1,2}.
                // If the JPEG encoder encounters data with BGR offsets as
                // {2,1,0} then it will make yet another copy of the data
                // which might as well be averted here.
                WritableRaster target = sampleModel.getSampleSize(0) == 8 ?
                    Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
                                                   im.getWidth(),
                                                   im.getHeight(),
                                                   sampleModel.getNumBands(),
                                                   new Point(im.getMinX(),
                                                             im.getMinY())) :
                    null;

                // Copy the data.
View Full Code Here

Examples of java.awt.image.SampleModel

     *
     * @param w The width in pixels.
     * @param h The height in pixels
     */
    public SampleModel createCompatibleSampleModel(int w, int h) {
        SampleModel ret=null;
        long size;
        int minBandOff=bandOffsets[0];
        int maxBandOff=bandOffsets[0];
        for (int i=1; i<bandOffsets.length; i++) {
            minBandOff = Math.min(minBandOff,bandOffsets[i]);
View Full Code Here

Examples of java.awt.image.SampleModel

        if (src == null) {
            throw
              new IllegalArgumentException("Null Source");
        }

        SampleModel srcSampleModel = src.getSampleModel();
        if (!isIntegralDataType(srcSampleModel)) {
            throw
              new IllegalArgumentException("Source Data Type must be an Integral Data Type");
        }

        // Validate rectangle.
        if (rect == null) {
            rect = src.getBounds();
        } else {
            rect = rect.intersection(src.getBounds());
        }

        if (dst != null) {
            rect = rect.intersection(dst.getBounds());
        }

        // Validate destination.
        SampleModel dstSampleModel;
        if (dst == null) {  // create dst according to table
            dstSampleModel = getDestSampleModel(srcSampleModel,
                                                rect.width, rect.height);
            dst =
                RasterFactory.createWritableRaster(dstSampleModel,
                                                   new Point(rect.x, rect.y));
        } else {
            dstSampleModel = dst.getSampleModel();

            if (dstSampleModel.getTransferType() != getDataType() ||
                dstSampleModel.getNumBands() !=
                getDestNumBands(srcSampleModel.getNumBands())) {
                throw new
                  IllegalArgumentException("Incompatible Destination Image");
            }
        }
View Full Code Here

Examples of java.awt.image.SampleModel

        return Object.class;
    }

    public boolean canEncodeImage(RenderedImage im,
                                  ImageEncodeParam param) {
        SampleModel sampleModel = im.getSampleModel();

        int dataType = sampleModel.getTransferType();
        if (dataType == DataBuffer.TYPE_FLOAT  ||
            dataType == DataBuffer.TYPE_DOUBLE ||
            sampleModel.getNumBands() != 1     ||
            sampleModel.getSampleSize(0) != 1) {
            return false;
        }

        return true;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.