java.awt.image.RasterFormatException Java Examples
The following examples show how to use
java.awt.image.RasterFormatException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ByteComponentRaster.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Creates a Writable subRaster given a region of the Raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this Raster to the upper-left corner * of the subRaster. A subset of the bands of the parent Raster may * be specified. If this is null, then all the bands are present in the * subRaster. A translation to the subRaster may also be specified. * Note that the subRaster will reference the same * DataBuffer as the parent Raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent Raster. */ 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) sm = sampleModel.createSubsetSampleModel(bandList); else sm = sampleModel; int deltaX = x0 - x; int deltaY = y0 - y; return new ByteComponentRaster(sm, dataBuffer, new Rectangle(x0, y0, width, height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #2
Source File: ByteBandedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ByteBandedRaster(sm, new Point(0,0)); }
Example #3
Source File: ByteComponentRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a Writable subRaster given a region of the Raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this Raster to the upper-left corner * of the subRaster. A subset of the bands of the parent Raster may * be specified. If this is null, then all the bands are present in the * subRaster. A translation to the subRaster may also be specified. * Note that the subRaster will reference the same * DataBuffer as the parent Raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent Raster. */ 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) sm = sampleModel.createSubsetSampleModel(bandList); else sm = sampleModel; int deltaX = x0 - x; int deltaY = y0 - y; return new ByteComponentRaster(sm, dataBuffer, new Rectangle(x0, y0, width, height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #4
Source File: ShortInterleavedRaster.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ShortInterleavedRaster(sm, new Point(0, 0)); }
Example #5
Source File: IntegerComponentRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a raster with the same band 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); return new IntegerComponentRaster(sm, new Point(0,0)); }
Example #6
Source File: ByteBandedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a ByteBandedRaster with the given sampleModel, * DataBuffer, and parent. DataBuffer must be a DataBufferShort and * SampleModel must be of type BandedSampleModel. * When translated into the base Raster's * coordinate system, aRegion must be contained by the base Raster. * Origin is the coordinate in the new Raster's coordinate system of * the origin of the base Raster. (The base Raster is the Raster's * ancestor which has no parent.) * * Note that this constructor should generally be called by other * constructors or create methods, it should not be used directly. * @param sampleModel The SampleModel that specifies the layout. * @param dataBuffer The DataBufferShort that contains the image data. * @param aRegion The Rectangle that specifies the image area. * @param origin The Point that specifies the origin. * @param parent The parent (if any) of this raster. */ public ByteBandedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point origin, ByteBandedRaster parent) { super(sampleModel, dataBuffer, aRegion, origin, parent); this.maxX = minX + width; this.maxY = minY + height; if (!(dataBuffer instanceof DataBufferByte)) { throw new RasterFormatException("ByteBandedRaster must have" + "byte DataBuffers"); } DataBufferByte dbb = (DataBufferByte)dataBuffer; if (sampleModel instanceof BandedSampleModel) { BandedSampleModel bsm = (BandedSampleModel)sampleModel; this.scanlineStride = bsm.getScanlineStride(); int bankIndices[] = bsm.getBankIndices(); int bandOffsets[] = bsm.getBandOffsets(); int dOffsets[] = dbb.getOffsets(); dataOffsets = new int[bankIndices.length]; data = new byte[bankIndices.length][]; int xOffset = aRegion.x - origin.x; int yOffset = aRegion.y - origin.y; for (int i = 0; i < bankIndices.length; i++) { data[i] = stealData(dbb, bankIndices[i]); dataOffsets[i] = dOffsets[bankIndices[i]] + xOffset + yOffset*scanlineStride + bandOffsets[i]; } } else { throw new RasterFormatException("ByteBandedRasters must have"+ "BandedSampleModels"); } verify(); }
Example #7
Source File: BytePackedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a Writable subRaster given a region of the Raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this Raster to the upper-left corner * of the subRaster. The bandList is ignored. * A translation to the subRaster may also be specified. * Note that the subRaster will reference the same * DataBuffer as the parent Raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent Raster. */ 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) { sm = sampleModel.createSubsetSampleModel(bandList); } else { sm = sampleModel; } int deltaX = x0 - x; int deltaY = y0 - y; return new BytePackedRaster(sm, dataBuffer, new Rectangle(x0, y0, width, height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #8
Source File: BytePackedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); return new BytePackedRaster(sm, new Point(0,0)); }
Example #9
Source File: IntegerInterleavedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a IntegerInterleavedRaster with the given SampleModel, * DataBuffer, and parent. DataBuffer must be a DataBufferInt and * SampleModel must be of type SinglePixelPackedSampleModel. * When translated into the base Raster's * coordinate system, aRegion must be contained by the base Raster. * Origin is the coodinate in the new Raster's coordinate system of * the origin of the base Raster. (The base Raster is the Raster's * ancestor which has no parent.) * * Note that this constructor should generally be called by other * constructors or create methods, it should not be used directly. * @param sampleModel The SampleModel that specifies the layout. * @param dataBuffer The DataBufferInt that contains the image data. * @param aRegion The Rectangle that specifies the image area. * @param origin The Point that specifies the origin. * @param parent The parent (if any) of this raster. */ public IntegerInterleavedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point origin, IntegerInterleavedRaster parent){ super(sampleModel,dataBuffer,aRegion,origin,parent); this.maxX = minX + width; this.maxY = minY + height; if (!(dataBuffer instanceof DataBufferInt)) { throw new RasterFormatException("IntegerInterleavedRasters must have" + "integer DataBuffers"); } DataBufferInt dbi = (DataBufferInt)dataBuffer; this.data = stealData(dbi, 0); if (sampleModel instanceof SinglePixelPackedSampleModel) { SinglePixelPackedSampleModel sppsm = (SinglePixelPackedSampleModel)sampleModel; this.scanlineStride = sppsm.getScanlineStride(); this.pixelStride = 1; this.dataOffsets = new int[1]; this.dataOffsets[0] = dbi.getOffset(); this.bandOffset = this.dataOffsets[0]; int xOffset = aRegion.x - origin.x; int yOffset = aRegion.y - origin.y; dataOffsets[0] += xOffset+yOffset*scanlineStride; this.numDataElems = sppsm.getNumDataElements(); } else { throw new RasterFormatException("IntegerInterleavedRasters must have"+ " SinglePixelPackedSampleModel"); } verify(); }
Example #10
Source File: IntegerInterleavedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a subraster given a region of the raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this raster to the upper-left corner * of the subraster. A subset of the bands of the parent Raster may * be specified. If this is null, then all the bands are present in the * subRaster. A translation to the subRaster may also be specified. * Note that the subraster will reference the same * DataBuffer as the parent raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent raster. */ 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 raster"); } if (y < this.minY) { throw new RasterFormatException("y lies outside raster"); } if ((x+width < x) || (x+width > this.minX + this.width)) { throw new RasterFormatException("(x + width) is outside raster"); } if ((y+height < y) || (y+height > this.minY + this.height)) { throw new RasterFormatException("(y + height) is outside raster"); } SampleModel sm; if (bandList != null) sm = sampleModel.createSubsetSampleModel(bandList); else sm = sampleModel; int deltaX = x0 - x; int deltaY = y0 - y; return new IntegerInterleavedRaster(sm, dataBuffer, new Rectangle(x0,y0,width,height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #11
Source File: IntegerInterleavedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a raster with the same band 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); return new IntegerInterleavedRaster(sm, new Point(0,0)); }
Example #12
Source File: ByteInterleavedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a Writable subRaster given a region of the Raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this Raster to the upper-left corner * of the subRaster. A subset of the bands of the parent Raster may * be specified. If this is null, then all the bands are present in the * subRaster. A translation to the subRaster may also be specified. * Note that the subRaster will reference the same * DataBuffer as the parent Raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent Raster. */ 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) sm = sampleModel.createSubsetSampleModel(bandList); else sm = sampleModel; int deltaX = x0 - x; int deltaY = y0 - y; return new ByteInterleavedRaster(sm, dataBuffer, new Rectangle(x0, y0, width, height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #13
Source File: ByteInterleavedRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ByteInterleavedRaster(sm, new Point(0,0)); }
Example #14
Source File: ShortComponentRaster.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ShortComponentRaster(sm, new Point(0, 0)); }
Example #15
Source File: ShortBandedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ShortBandedRaster(sm, new Point(0,0)); }
Example #16
Source File: ShortBandedRaster.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ShortBandedRaster(sm, new Point(0,0)); }
Example #17
Source File: ShortBandedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a ShortBandedRaster with the given SampleModel, * DataBuffer, and parent. DataBuffer must be a DataBufferUShort and * SampleModel must be of type BandedSampleModel. * When translated into the base Raster's * coordinate system, aRegion must be contained by the base Raster. * Origin is the coordinate in the new Raster's coordinate system of * the origin of the base Raster. (The base Raster is the Raster's * ancestor which has no parent.) * * Note that this constructor should generally be called by other * constructors or create methods, it should not be used directly. * @param sampleModel The SampleModel that specifies the layout. * @param dataBuffer The DataBufferUShort that contains the image data. * @param aRegion The Rectangle that specifies the image area. * @param origin The Point that specifies the origin. * @param parent The parent (if any) of this raster. */ public ShortBandedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point origin, ShortBandedRaster parent) { super(sampleModel, dataBuffer, aRegion, origin, parent); this.maxX = minX + width; this.maxY = minY + height; if (!(dataBuffer instanceof DataBufferUShort)) { throw new RasterFormatException("ShortBandedRaster must have " + "ushort DataBuffers"); } DataBufferUShort dbus = (DataBufferUShort)dataBuffer; if (sampleModel instanceof BandedSampleModel) { BandedSampleModel bsm = (BandedSampleModel)sampleModel; this.scanlineStride = bsm.getScanlineStride(); int bankIndices[] = bsm.getBankIndices(); int bandOffsets[] = bsm.getBandOffsets(); int dOffsets[] = dbus.getOffsets(); dataOffsets = new int[bankIndices.length]; data = new short[bankIndices.length][]; int xOffset = aRegion.x - origin.x; int yOffset = aRegion.y - origin.y; for (int i = 0; i < bankIndices.length; i++) { data[i] = stealData(dbus, bankIndices[i]); dataOffsets[i] = dOffsets[bankIndices[i]] + xOffset + yOffset*scanlineStride + bandOffsets[i]; } } else { throw new RasterFormatException("ShortBandedRasters must have "+ "BandedSampleModels"); } verify(); }
Example #18
Source File: ShortInterleavedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a Writable subRaster given a region of the Raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this Raster to the upper-left corner * of the subRaster. A subset of the bands of the parent Raster may * be specified. If this is null, then all the bands are present in the * subRaster. A translation to the subRaster may also be specified. * Note that the subRaster will reference the same * DataBuffers as the parent Raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent Raster. */ 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) sm = sampleModel.createSubsetSampleModel(bandList); else sm = sampleModel; int deltaX = x0 - x; int deltaY = y0 - y; return new ShortInterleavedRaster(sm, dataBuffer, new Rectangle(x0, y0, width, height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #19
Source File: IntegerComponentRaster.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Creates a raster with the same band 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); return new IntegerComponentRaster(sm, new Point(0,0)); }
Example #20
Source File: IntegerInterleavedRaster.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Creates a subraster given a region of the raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this raster to the upper-left corner * of the subraster. A subset of the bands of the parent Raster may * be specified. If this is null, then all the bands are present in the * subRaster. A translation to the subRaster may also be specified. * Note that the subraster will reference the same * DataBuffer as the parent raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent raster. */ 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 raster"); } if (y < this.minY) { throw new RasterFormatException("y lies outside raster"); } if ((x+width < x) || (x+width > this.minX + this.width)) { throw new RasterFormatException("(x + width) is outside raster"); } if ((y+height < y) || (y+height > this.minY + this.height)) { throw new RasterFormatException("(y + height) is outside raster"); } SampleModel sm; if (bandList != null) sm = sampleModel.createSubsetSampleModel(bandList); else sm = sampleModel; int deltaX = x0 - x; int deltaY = y0 - y; return new IntegerInterleavedRaster(sm, dataBuffer, new Rectangle(x0,y0,width,height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #21
Source File: IntegerInterleavedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a raster with the same band 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); return new IntegerInterleavedRaster(sm, new Point(0,0)); }
Example #22
Source File: ShortInterleavedRaster.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Creates a Writable subRaster given a region of the Raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this Raster to the upper-left corner * of the subRaster. A subset of the bands of the parent Raster may * be specified. If this is null, then all the bands are present in the * subRaster. A translation to the subRaster may also be specified. * Note that the subRaster will reference the same * DataBuffers as the parent Raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent Raster. */ 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) sm = sampleModel.createSubsetSampleModel(bandList); else sm = sampleModel; int deltaX = x0 - x; int deltaY = y0 - y; return new ShortInterleavedRaster(sm, dataBuffer, new Rectangle(x0, y0, width, height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #23
Source File: IntegerInterleavedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a IntegerInterleavedRaster with the given SampleModel, * DataBuffer, and parent. DataBuffer must be a DataBufferInt and * SampleModel must be of type SinglePixelPackedSampleModel. * When translated into the base Raster's * coordinate system, aRegion must be contained by the base Raster. * Origin is the coodinate in the new Raster's coordinate system of * the origin of the base Raster. (The base Raster is the Raster's * ancestor which has no parent.) * * Note that this constructor should generally be called by other * constructors or create methods, it should not be used directly. * @param sampleModel The SampleModel that specifies the layout. * @param dataBuffer The DataBufferInt that contains the image data. * @param aRegion The Rectangle that specifies the image area. * @param origin The Point that specifies the origin. * @param parent The parent (if any) of this raster. */ public IntegerInterleavedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point origin, IntegerInterleavedRaster parent){ super(sampleModel,dataBuffer,aRegion,origin,parent); this.maxX = minX + width; this.maxY = minY + height; if (!(dataBuffer instanceof DataBufferInt)) { throw new RasterFormatException("IntegerInterleavedRasters must have" + "integer DataBuffers"); } DataBufferInt dbi = (DataBufferInt)dataBuffer; this.data = stealData(dbi, 0); if (sampleModel instanceof SinglePixelPackedSampleModel) { SinglePixelPackedSampleModel sppsm = (SinglePixelPackedSampleModel)sampleModel; this.scanlineStride = sppsm.getScanlineStride(); this.pixelStride = 1; this.dataOffsets = new int[1]; this.dataOffsets[0] = dbi.getOffset(); this.bandOffset = this.dataOffsets[0]; int xOffset = aRegion.x - origin.x; int yOffset = aRegion.y - origin.y; dataOffsets[0] += xOffset+yOffset*scanlineStride; this.numDataElems = sppsm.getNumDataElements(); } else { throw new RasterFormatException("IntegerInterleavedRasters must have"+ " SinglePixelPackedSampleModel"); } verify(); }
Example #24
Source File: BytePackedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); return new BytePackedRaster(sm, new Point(0,0)); }
Example #25
Source File: BytePackedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a Writable subRaster given a region of the Raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this Raster to the upper-left corner * of the subRaster. The bandList is ignored. * A translation to the subRaster may also be specified. * Note that the subRaster will reference the same * DataBuffer as the parent Raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width (in pixels) of the subraster. * @param height Height (in pixels) of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent Raster. */ 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) { sm = sampleModel.createSubsetSampleModel(bandList); } else { sm = sampleModel; } int deltaX = x0 - x; int deltaY = y0 - y; return new BytePackedRaster(sm, dataBuffer, new Rectangle(x0, y0, width, height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #26
Source File: ShortComponentRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ShortComponentRaster(sm, new Point(0, 0)); }
Example #27
Source File: ShortComponentRaster.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ShortComponentRaster(sm, new Point(0, 0)); }
Example #28
Source File: ByteBandedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); return new ByteBandedRaster(sm, new Point(0,0)); }
Example #29
Source File: ByteBandedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a Writable subraster given a region of the raster. The x and y * coordinates specify the horizontal and vertical offsets * from the upper-left corner of this raster to the upper-left corner * of the subraster. A subset of the bands of the parent Raster may * be specified. If this is null, then all the bands are present in the * subRaster. A translation to the subRaster may also be specified. * Note that the subraster will reference the same * DataBuffers as the parent raster, but using different offsets. * @param x X offset. * @param y Y offset. * @param width Width of the subraster. * @param height Height of the subraster. * @param x0 Translated X origin of the subraster. * @param y0 Translated Y origin of the subraster. * @param bandList Array of band indices. * @exception RasterFormatException * if the specified bounding box is outside of the parent raster. */ 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 raster"); } if (y < this.minY) { throw new RasterFormatException("y lies outside raster"); } if ((x+width < x) || (x+width > this.width + this.minX)) { throw new RasterFormatException("(x + width) is outside raster") ; } if ((y+height < y) || (y+height > this.height + this.minY)) { throw new RasterFormatException("(y + height) is outside raster"); } SampleModel sm; if (bandList != null) sm = sampleModel.createSubsetSampleModel(bandList); else sm = sampleModel; int deltaX = x0 - x; int deltaY = y0 - y; return new ByteBandedRaster(sm, dataBuffer, new Rectangle(x0,y0,width,height), new Point(sampleModelTranslateX+deltaX, sampleModelTranslateY+deltaY), this); }
Example #30
Source File: ByteBandedRaster.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a ByteBandedRaster with the given sampleModel, * DataBuffer, and parent. DataBuffer must be a DataBufferShort and * SampleModel must be of type BandedSampleModel. * When translated into the base Raster's * coordinate system, aRegion must be contained by the base Raster. * Origin is the coordinate in the new Raster's coordinate system of * the origin of the base Raster. (The base Raster is the Raster's * ancestor which has no parent.) * * Note that this constructor should generally be called by other * constructors or create methods, it should not be used directly. * @param sampleModel The SampleModel that specifies the layout. * @param dataBuffer The DataBufferShort that contains the image data. * @param aRegion The Rectangle that specifies the image area. * @param origin The Point that specifies the origin. * @param parent The parent (if any) of this raster. */ public ByteBandedRaster(SampleModel sampleModel, DataBuffer dataBuffer, Rectangle aRegion, Point origin, ByteBandedRaster parent) { super(sampleModel, dataBuffer, aRegion, origin, parent); this.maxX = minX + width; this.maxY = minY + height; if (!(dataBuffer instanceof DataBufferByte)) { throw new RasterFormatException("ByteBandedRaster must have" + "byte DataBuffers"); } DataBufferByte dbb = (DataBufferByte)dataBuffer; if (sampleModel instanceof BandedSampleModel) { BandedSampleModel bsm = (BandedSampleModel)sampleModel; this.scanlineStride = bsm.getScanlineStride(); int bankIndices[] = bsm.getBankIndices(); int bandOffsets[] = bsm.getBandOffsets(); int dOffsets[] = dbb.getOffsets(); dataOffsets = new int[bankIndices.length]; data = new byte[bankIndices.length][]; int xOffset = aRegion.x - origin.x; int yOffset = aRegion.y - origin.y; for (int i = 0; i < bankIndices.length; i++) { data[i] = stealData(dbb, bankIndices[i]); dataOffsets[i] = dOffsets[bankIndices[i]] + xOffset + yOffset*scanlineStride + bandOffsets[i]; } } else { throw new RasterFormatException("ByteBandedRasters must have"+ "BandedSampleModels"); } verify(); }