< prev index next >
src/java.desktop/share/classes/java/awt/image/SinglePixelPackedSampleModel.java
Print this page
*** 53,64 ****
* required to extract the samples representing the bands of the pixel.
* Bit offsets are the offsets in bits into the data array
* element of the samples representing the bands of the pixel.
* <p>
* The following code illustrates extracting the bits of the sample
! * representing band <code>b</code> for pixel <code>x,y</code>
! * from DataBuffer <code>data</code>:
* <pre>{@code
* int sample = data.getElem(y * scanlineStride + x);
* sample = (sample & bitMasks[b]) >>> bitOffsets[b];
* }</pre>
*/
--- 53,64 ----
* required to extract the samples representing the bands of the pixel.
* Bit offsets are the offsets in bits into the data array
* element of the samples representing the bands of the pixel.
* <p>
* The following code illustrates extracting the bits of the sample
! * representing band {@code b} for pixel {@code x,y}
! * from DataBuffer {@code data}:
* <pre>{@code
* int sample = data.getElem(y * scanlineStride + x);
* sample = (sample & bitMasks[b]) >>> bitOffsets[b];
* }</pre>
*/
*** 98,111 ****
* @param w The width (in pixels) of the region of the
* image data described.
* @param h The height (in pixels) of the region of the
* image data described.
* @param bitMasks The bit masks for all bands.
! * @throws IllegalArgumentException if <code>dataType</code> is not
! * either <code>DataBuffer.TYPE_BYTE</code>,
! * <code>DataBuffer.TYPE_USHORT</code>, or
! * <code>DataBuffer.TYPE_INT</code>
*/
public SinglePixelPackedSampleModel(int dataType, int w, int h,
int bitMasks[]) {
this(dataType, w, h, w, bitMasks);
if (dataType != DataBuffer.TYPE_BYTE &&
--- 98,111 ----
* @param w The width (in pixels) of the region of the
* image data described.
* @param h The height (in pixels) of the region of the
* image data described.
* @param bitMasks The bit masks for all bands.
! * @throws IllegalArgumentException if {@code dataType} is not
! * either {@code DataBuffer.TYPE_BYTE},
! * {@code DataBuffer.TYPE_USHORT}, or
! * {@code DataBuffer.TYPE_INT}
*/
public SinglePixelPackedSampleModel(int dataType, int w, int h,
int bitMasks[]) {
this(dataType, w, h, w, bitMasks);
if (dataType != DataBuffer.TYPE_BYTE &&
*** 128,145 ****
* image data described.
* @param h The height (in pixels) of the region of
* image data described.
* @param scanlineStride The line stride of the image data.
* @param bitMasks The bit masks for all bands.
! * @throws IllegalArgumentException if <code>w</code> or
! * <code>h</code> is not greater than 0
* @throws IllegalArgumentException if any mask in
! * <code>bitMask</code> is not contiguous
! * @throws IllegalArgumentException if <code>dataType</code> is not
! * either <code>DataBuffer.TYPE_BYTE</code>,
! * <code>DataBuffer.TYPE_USHORT</code>, or
! * <code>DataBuffer.TYPE_INT</code>
*/
public SinglePixelPackedSampleModel(int dataType, int w, int h,
int scanlineStride, int bitMasks[]) {
super(dataType, w, h, bitMasks.length);
if (dataType != DataBuffer.TYPE_BYTE &&
--- 128,145 ----
* image data described.
* @param h The height (in pixels) of the region of
* image data described.
* @param scanlineStride The line stride of the image data.
* @param bitMasks The bit masks for all bands.
! * @throws IllegalArgumentException if {@code w} or
! * {@code h} is not greater than 0
* @throws IllegalArgumentException if any mask in
! * {@code bitMask} is not contiguous
! * @throws IllegalArgumentException if {@code dataType} is not
! * either {@code DataBuffer.TYPE_BYTE},
! * {@code DataBuffer.TYPE_USHORT}, or
! * {@code DataBuffer.TYPE_INT}
*/
public SinglePixelPackedSampleModel(int dataType, int w, int h,
int scanlineStride, int bitMasks[]) {
super(dataType, w, h, bitMasks.length);
if (dataType != DataBuffer.TYPE_BYTE &&
*** 206,221 ****
/**
* Creates a new SinglePixelPackedSampleModel with the specified
* width and height. The new SinglePixelPackedSampleModel will have the
* same storage data type and bit masks as this
* SinglePixelPackedSampleModel.
! * @param w the width of the resulting <code>SampleModel</code>
! * @param h the height of the resulting <code>SampleModel</code>
! * @return a <code>SinglePixelPackedSampleModel</code> with the
* specified width and height.
! * @throws IllegalArgumentException if <code>w</code> or
! * <code>h</code> is not greater than 0
*/
public SampleModel createCompatibleSampleModel(int w, int h) {
SampleModel sampleModel = new SinglePixelPackedSampleModel(dataType, w, h,
bitMasks);
return sampleModel;
--- 206,221 ----
/**
* Creates a new SinglePixelPackedSampleModel with the specified
* width and height. The new SinglePixelPackedSampleModel will have the
* same storage data type and bit masks as this
* SinglePixelPackedSampleModel.
! * @param w the width of the resulting {@code SampleModel}
! * @param h the height of the resulting {@code SampleModel}
! * @return a {@code SinglePixelPackedSampleModel} with the
* specified width and height.
! * @throws IllegalArgumentException if {@code w} or
! * {@code h} is not greater than 0
*/
public SampleModel createCompatibleSampleModel(int w, int h) {
SampleModel sampleModel = new SinglePixelPackedSampleModel(dataType, w, h,
bitMasks);
return sampleModel;
*** 254,266 ****
public int getSampleSize(int band) {
return bitSizes[band];
}
/** Returns the offset (in data array elements) of pixel (x,y).
! * The data element containing pixel <code>x,y</code>
! * can be retrieved from a DataBuffer <code>data</code> with a
! * SinglePixelPackedSampleModel <code>sppsm</code> as:
* <pre>
* data.getElem(sppsm.getOffset(x, y));
* </pre>
* @param x the X coordinate of the specified pixel
* @param y the Y coordinate of the specified pixel
--- 254,266 ----
public int getSampleSize(int band) {
return bitSizes[band];
}
/** Returns the offset (in data array elements) of pixel (x,y).
! * The data element containing pixel {@code x,y}
! * can be retrieved from a DataBuffer {@code data} with a
! * SinglePixelPackedSampleModel {@code sppsm} as:
* <pre>
* data.getElem(sppsm.getOffset(x, y));
* </pre>
* @param x the X coordinate of the specified pixel
* @param y the Y coordinate of the specified pixel
*** 286,296 ****
return bitMasks.clone();
}
/** Returns the scanline stride of this SinglePixelPackedSampleModel.
* @return the scanline stride of this
! * <code>SinglePixelPackedSampleModel</code>.
*/
public int getScanlineStride() {
return scanlineStride;
}
--- 286,296 ----
return bitMasks.clone();
}
/** Returns the scanline stride of this SinglePixelPackedSampleModel.
* @return the scanline stride of this
! * {@code SinglePixelPackedSampleModel}.
*/
public int getScanlineStride() {
return scanlineStride;
}
*** 326,339 ****
* data type. Generally, obj
* should be passed in as null, so that the Object will be created
* automatically and will be of the right primitive data type.
* <p>
* The following code illustrates transferring data for one pixel from
! * DataBuffer <code>db1</code>, whose storage layout is described by
! * SinglePixelPackedSampleModel <code>sppsm1</code>, to
! * DataBuffer <code>db2</code>, whose storage layout is described by
! * SinglePixelPackedSampleModel <code>sppsm2</code>.
* The transfer will generally be more efficient than using
* getPixel/setPixel.
* <pre>
* SinglePixelPackedSampleModel sppsm1, sppsm2;
* DataBufferInt db1, db2;
--- 326,339 ----
* data type. Generally, obj
* should be passed in as null, so that the Object will be created
* automatically and will be of the right primitive data type.
* <p>
* The following code illustrates transferring data for one pixel from
! * DataBuffer {@code db1}, whose storage layout is described by
! * SinglePixelPackedSampleModel {@code sppsm1}, to
! * DataBuffer {@code db2}, whose storage layout is described by
! * SinglePixelPackedSampleModel {@code sppsm2}.
* The transfer will generally be more efficient than using
* getPixel/setPixel.
* <pre>
* SinglePixelPackedSampleModel sppsm1, sppsm2;
* DataBufferInt db1, db2;
*** 564,577 ****
* SinglePixelPackedSampleModel, only the first element of the array
* will hold valid data, and the type of the array must be the same as
* the storage data type of the SinglePixelPackedSampleModel.
* <p>
* The following code illustrates transferring data for one pixel from
! * DataBuffer <code>db1</code>, whose storage layout is described by
! * SinglePixelPackedSampleModel <code>sppsm1</code>,
! * to DataBuffer <code>db2</code>, whose storage layout is described by
! * SinglePixelPackedSampleModel <code>sppsm2</code>.
* The transfer will generally be more efficient than using
* getPixel/setPixel.
* <pre>
* SinglePixelPackedSampleModel sppsm1, sppsm2;
* DataBufferInt db1, db2;
--- 564,577 ----
* SinglePixelPackedSampleModel, only the first element of the array
* will hold valid data, and the type of the array must be the same as
* the storage data type of the SinglePixelPackedSampleModel.
* <p>
* The following code illustrates transferring data for one pixel from
! * DataBuffer {@code db1}, whose storage layout is described by
! * SinglePixelPackedSampleModel {@code sppsm1},
! * to DataBuffer {@code db2}, whose storage layout is described by
! * SinglePixelPackedSampleModel {@code sppsm2}.
* The transfer will generally be more efficient than using
* getPixel/setPixel.
* <pre>
* SinglePixelPackedSampleModel sppsm1, sppsm2;
* DataBufferInt db1, db2;
< prev index next >