Package java.awt.image

Examples of java.awt.image.RasterFormatException


     * Creates a raster with the same layout but using a different
     * width and height, and with new zeroed data arrays.
     */
    public WritableRaster createCompatibleWritableRaster(int w, int h) {
        if (w <= 0 || h <=0) {
            throw new RasterFormatException("negative "+
                                          ((w <= 0) ? "width" : "height"));
        }

        SampleModel sm = sampleModel.createCompatibleSampleModel(w,h);

View Full Code Here


     *                    the data.  Otherwise returns null.
     */
    private void verify (boolean strictCheck) {
        // Make sure data for Raster is in a legal range
        if (dataBitOffset < 0) {
            throw new RasterFormatException("Data offsets must be >= 0");
        }

        int lastbit = (dataBitOffset
                       + (height-1) * scanlineStride * 8
                       + (width-1) * pixelBitStride
                       + pixelBitStride - 1);
        if (lastbit / 8 >= data.length) {
            throw new RasterFormatException("raster dimensions overflow " +
                                            "array bounds");
        }
        if (strictCheck) {
            if (height > 1) {
                lastbit = width * pixelBitStride - 1;
                if (lastbit / 8 >= scanlineStride) {
                    throw new RasterFormatException("data for adjacent" +
                                                    " scanlines overlaps");
                }
            }
        }
    }
View Full Code Here

        super(sampleModel, dataBuffer, aRegion, origin, parent);
        this.maxX = minX + width;
        this.maxY = minY + height;

        if(!(dataBuffer instanceof DataBufferUShort)) {
            throw new RasterFormatException("ShortComponentRasters must have "+
                                            "short DataBuffers");
        }

        DataBufferUShort dbus = (DataBufferUShort)dataBuffer;
        this.data = stealData(dbus, 0);
        if (dbus.getNumBanks() != 1) {
            throw new
                RasterFormatException("DataBuffer for ShortComponentRasters"+
                                      " must only have 1 bank.");
        }
        int dbOffset = dbus.getOffset();

        if (sampleModel instanceof ComponentSampleModel) {
            ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
            this.type = IntegerComponentRaster.TYPE_USHORT_SAMPLES;
            this.scanlineStride = csm.getScanlineStride();
            this.pixelStride = csm.getPixelStride();
            this.dataOffsets = csm.getBandOffsets();
            int xOffset = aRegion.x - origin.x;
            int yOffset = aRegion.y - origin.y;
            for (int i = 0; i < getNumDataElements(); i++) {
                dataOffsets[i] += dbOffset +
                    xOffset*pixelStride+yOffset*scanlineStride;
            }
        } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
            SinglePixelPackedSampleModel sppsm =
                    (SinglePixelPackedSampleModel)sampleModel;
            this.type = IntegerComponentRaster.TYPE_USHORT_PACKED_SAMPLES;
            this.scanlineStride = sppsm.getScanlineStride();
            this.pixelStride    = 1;
            this.dataOffsets = new int[1];
            this.dataOffsets[0] = dbOffset;
            int xOffset = aRegion.x - origin.x;
            int yOffset = aRegion.y - origin.y;
            dataOffsets[0] += xOffset+yOffset*scanlineStride;
        } else {
            throw new RasterFormatException("ShortComponentRasters must have"+
                "ComponentSampleModel or SinglePixelPackedSampleModel");
        }
        this.bandOffset = this.dataOffsets[0];

        verify(false);
View Full Code Here

    public WritableRaster createWritableChild(int x, int y,
                                              int width, int height,
                                              int x0, int y0,
                                              int[] bandList) {
        if (x < this.minX) {
            throw new RasterFormatException("x lies outside the raster");
        }
        if (y < this.minY) {
            throw new RasterFormatException("y lies outside the raster");
        }
        if ((x+width < x) || (x+width > this.minX + this.width)) {
            throw new RasterFormatException("(x + width) is outside of Raster");
        }
        if ((y+height < y) || (y+height > this.minY + this.height)) {
            throw new RasterFormatException("(y + height) is outside of Raster");
        }

        SampleModel sm;

        if (bandList != null)
View Full Code Here

     * Creates a Raster with the same layout but using a different
     * width and height, and with new zeroed data arrays.
     */
    public WritableRaster createCompatibleWritableRaster(int w, int h) {
        if (w <= 0 || h <=0) {
            throw new RasterFormatException("negative "+
                                          ((w <= 0) ? "width" : "height"));
        }

        SampleModel sm = sampleModel.createCompatibleSampleModel(w, h);

View Full Code Here

     */
    private void verify (boolean strictCheck) {
        // Make sure data for Raster is in a legal range
        for (int i=0; i < dataOffsets.length; i++) {
            if (dataOffsets[i] < 0) {
                throw new RasterFormatException("Data offsets for band "+i+
                                                "("+dataOffsets[i]+
                                                ") must be >= 0");
            }
        }

        int maxSize = 0;
        int size;

        for (int i=0; i < numDataElements; i++) {
            size = (height-1)*scanlineStride + (width-1)*pixelStride +
                dataOffsets[i];
            if (size > maxSize) {
                maxSize = size;
            }
        }
        if (data.length < maxSize) {
            throw new RasterFormatException("Data array too small (should be "+
                                          maxSize+" )");
        }
    }
View Full Code Here

/*      */   }
/*      */
/*      */   public static WritableRaster createWritableChild(WritableRaster raster, int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList)
/*      */   {
/*  798 */     if (parentX < raster.getMinX()) {
/*  799 */       throw new RasterFormatException(JaiI18N.getString("RasterFactory9"));
/*      */     }
/*  801 */     if (parentY < raster.getMinY()) {
/*  802 */       throw new RasterFormatException(JaiI18N.getString("RasterFactory10"));
/*      */     }
/*      */
/*  805 */     if (parentX + width > raster.getWidth() + raster.getMinX()) {
/*  806 */       throw new RasterFormatException(JaiI18N.getString("RasterFactory11"));
/*      */     }
/*      */
/*  809 */     if (parentY + height > raster.getHeight() + raster.getMinY()) {
/*  810 */       throw new RasterFormatException(JaiI18N.getString("RasterFactory12"));
/*      */     }
/*      */
/*  814 */     SampleModel sampleModel = raster.getSampleModel();
/*  815 */     DataBuffer dataBuffer = raster.getDataBuffer();
/*  816 */     int sampleModelTranslateX = raster.getSampleModelTranslateX();
View Full Code Here

/*      */   }
/*      */
/*      */   public static WritableRaster createWritableChild(WritableRaster raster, int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList)
/*      */   {
/*  798 */     if (parentX < raster.getMinX()) {
/*  799 */       throw new RasterFormatException(JaiI18N.getString("RasterFactory9"));
/*      */     }
/*  801 */     if (parentY < raster.getMinY()) {
/*  802 */       throw new RasterFormatException(JaiI18N.getString("RasterFactory10"));
/*      */     }
/*      */
/*  805 */     if (parentX + width > raster.getWidth() + raster.getMinX()) {
/*  806 */       throw new RasterFormatException(JaiI18N.getString("RasterFactory11"));
/*      */     }
/*      */
/*  809 */     if (parentY + height > raster.getHeight() + raster.getMinY()) {
/*  810 */       throw new RasterFormatException(JaiI18N.getString("RasterFactory12"));
/*      */     }
/*      */
/*  814 */     SampleModel sampleModel = raster.getSampleModel();
/*  815 */     DataBuffer dataBuffer = raster.getDataBuffer();
/*  816 */     int sampleModelTranslateX = raster.getSampleModelTranslateX();
View Full Code Here

                  last = domainSearch(iterator, last,bandNumber);

              } while (!iterator.nextPixelDone());
          } while (!iterator.nextLineDone());
      } catch (final Exception cause) {
        final RasterFormatException exception = new RasterFormatException(
            cause.getLocalizedMessage());
        exception.initCause(cause);
        throw exception;
      }
      bandNumber++;
    } while (iterator.finishedBands());
  }
View Full Code Here

                                                     int height,
                                                     int childMinX,
                                                     int childMinY,
                                                     int bandList[]) {
        if (parentX < raster.getMinX()) {
            throw new RasterFormatException(JaiI18N.getString("RasterFactory9"));
        }
        if (parentY < raster.getMinY()) {
            throw new
    RasterFormatException(JaiI18N.getString("RasterFactory10"));
        }
        if (parentX + width > raster.getWidth() + raster.getMinX()) {
            throw new
    RasterFormatException(JaiI18N.getString("RasterFactory11"));
        }
        if (parentY + height > raster.getHeight() + raster.getMinY()) {
            throw new
    RasterFormatException(JaiI18N.getString("RasterFactory12"));
        }

        SampleModel sampleModel = raster.getSampleModel();
        DataBuffer dataBuffer = raster.getDataBuffer();
View Full Code Here

TOP

Related Classes of java.awt.image.RasterFormatException

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.