Examples of SampleModel


Examples of java.awt.image.SampleModel

        super(output, param);
    }

    public void encode(RenderedImage im) throws IOException {
        // Get the SampleModel.
        SampleModel sm = im.getSampleModel();

        // Check the data type, band count, and sample size.
        int dataType = sm.getTransferType();
        if (dataType == DataBuffer.TYPE_FLOAT ||
            dataType == DataBuffer.TYPE_DOUBLE) {
            throw new IllegalArgumentException(JaiI18N.getString("WBMPImageEncoder0"));
        } else if (sm.getNumBands() != 1) {
            throw new IllegalArgumentException(JaiI18N.getString("WBMPImageEncoder1"));
        } else if (sm.getSampleSize(0) != 1) {
            throw new IllegalArgumentException(JaiI18N.getString("WBMPImageEncoder2"));
        }

        // Save image dimensions.
        int width = im.getWidth();
        int height = im.getHeight();

        // Write WBMP header.
        output.write(0); // TypeField
        output.write(0); // FixHeaderField
        output.write(intToMultiByte(width)); // width
        output.write(intToMultiByte(height)); // height

        Raster tile = null;

        // If the data are not formatted nominally then reformat.
        if(sm.getDataType() != DataBuffer.TYPE_BYTE ||
           !(sm instanceof MultiPixelPackedSampleModel) ||
           ((MultiPixelPackedSampleModel)sm).getDataBitOffset() != 0) {
            MultiPixelPackedSampleModel mppsm =
                new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                width, height, 1,
View Full Code Here

Examples of java.awt.image.SampleModel

        // Handle the special case of adding a single band image to
        // each band of a multi-band image.
        int numBandsDst;
        if (layout != null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
            SampleModel sm = layout.getSampleModel(null);
            numBandsDst = sm.getNumBands();

            // One of the sources must be single-banded and the other must
            // have at most the number of bands in the SampleModel hint.
            if (numBandsDst > 1 &&
                ((numBands1 == 1 && numBands2 > 1) ||
View Full Code Here

Examples of java.awt.image.SampleModel

     *
     * @param src The <code>RenderedImage</code> to test.
     * @return Whether the image is byte-packed.
     */
    static final boolean isPackedByteImage(RenderedImage im) {
        SampleModel imageSampleModel = im.getSampleModel();

        if(imageSampleModel instanceof SinglePixelPackedSampleModel) {
            for(int i = 0; i < imageSampleModel.getNumBands(); i++) {
                if(imageSampleModel.getSampleSize(i) > 8) {
                    return false;
                }
            }

            return true;
View Full Code Here

Examples of java.awt.image.SampleModel

    JaiI18N.getString("JPEGTileDecoder0") );
  return decode(null);
    }

    public Raster decode(Point location) throws IOException{
  SampleModel sm = null;
  byte[] data = null;

        ObjectInputStream ois = new ObjectInputStream(inputStream);

        try {
View Full Code Here

Examples of java.awt.image.SampleModel

      return true;

  RenderedImage src = args.getRenderedSource(0);

        double[][] matrix = (double[][])args.getObjectParameter(0);
        SampleModel sm = src.getSampleModel();
        int rowLength = sm.getNumBands() + 1;

        if (matrix.length < 1) {
            message.append(getName() + ": " +
                           "bad matrix dimensions");
            return false;
View Full Code Here

Examples of java.awt.image.SampleModel

     * <code>false</code> with the <code>SampleModel</code> of the
     * supplied <code>Raster</code> as argument.
     */
    public static byte[] getPackedBinaryData(Raster raster,
                                             Rectangle rect) {
        SampleModel sm = raster.getSampleModel();
        if(!isBinary(sm)) {
            throw new IllegalArgumentException(JaiI18N.getString("ImageUtil0"));
        }

        int rectX = rect.x;
View Full Code Here

Examples of java.awt.image.SampleModel

     * <code>false</code> with the <code>SampleModel</code> of the
     * supplied <code>Raster</code> as argument.
     */
    public static byte[] getUnpackedBinaryData(Raster raster,
                                               Rectangle rect) {
        SampleModel sm = raster.getSampleModel();
        if(!isBinary(sm)) {
            throw new IllegalArgumentException(JaiI18N.getString("ImageUtil0"));
        }

        int rectX = rect.x;
View Full Code Here

Examples of java.awt.image.SampleModel

     * supplied <code>Raster</code> as argument.
     */
    public static void setPackedBinaryData(byte[] binaryDataArray,
                                           WritableRaster raster,
                                           Rectangle rect) {
        SampleModel sm = raster.getSampleModel();
        if(!isBinary(sm)) {
            throw new IllegalArgumentException(JaiI18N.getString("ImageUtil0"));
        }

        int rectX = rect.x;
View Full Code Here

Examples of java.awt.image.SampleModel

     * supplied <code>Raster</code> as argument.
     */
    public static void setUnpackedBinaryData(byte[] bdata,
                                             WritableRaster raster,
                                             Rectangle rect) {
        SampleModel sm = raster.getSampleModel();
        if(!isBinary(sm)) {
            throw new IllegalArgumentException(JaiI18N.getString("ImageUtil0"));
        }

        int rectX = rect.x;
View Full Code Here

Examples of java.awt.image.SampleModel

    public static void fillBackground(WritableRaster raster,
              Rectangle rect,
              double[] backgroundValues) {
  rect = rect.intersection(raster.getBounds());
  int numBands = raster.getSampleModel().getNumBands();
        SampleModel sm = raster.getSampleModel();
        PixelAccessor accessor = new PixelAccessor(sm, null);

        if (isBinary(sm)) {
            //fill binary data
            byte value = (byte)(((int)backgroundValues[0]) & 1);
            if (value == 0)
                return;
            int rectX = rect.x;
            int rectY = rect.y;
            int rectWidth = rect.width;
            int rectHeight = rect.height;

            int dx = rectX - raster.getSampleModelTranslateX();
            int dy = rectY - raster.getSampleModelTranslateY();

            DataBuffer dataBuffer = raster.getDataBuffer();
            MultiPixelPackedSampleModel mpp = (MultiPixelPackedSampleModel)sm;
            int lineStride = mpp.getScanlineStride();
            int eltOffset = dataBuffer.getOffset() + mpp.getOffset(dx, dy);
            int bitOffset = mpp.getBitOffset(dx);

            switch(sm.getDataType()) {
            case DataBuffer.TYPE_BYTE:
                {
                    byte[] data = ((DataBufferByte)dataBuffer).getData();
                    int bits = bitOffset & 7;
                    int otherBits = (bits == 0) ? 0: 8 - bits;
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.