This removes one usage of the Buffers class from
SinglePixelPackedSampleModel (the Buffers class covers more than is
supported by the SPPSM).
2007-03-09 Roman Kennke <[EMAIL PROTECTED]>
* java/awt/image/SinglePixelPackageSampleModel.java
(createDataBuffer): Avoid use of Buffers class and create
DataBuffer directly in place.
/Roman
--
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com * Tel: +49-721-663 968-0
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
Index: java/awt/image/SinglePixelPackedSampleModel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/image/SinglePixelPackedSampleModel.java,v
retrieving revision 1.16
diff -u -1 -5 -r1.16 SinglePixelPackedSampleModel.java
--- java/awt/image/SinglePixelPackedSampleModel.java 10 Feb 2007 13:17:36 -0000 1.16
+++ java/awt/image/SinglePixelPackedSampleModel.java 9 Mar 2007 10:17:26 -0000
@@ -27,31 +27,30 @@
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image;
import java.util.Arrays;
import gnu.java.awt.BitMaskExtent;
-import gnu.java.awt.Buffers;
/**
* A <code>SampleModel</code> used when all samples are stored in a single
* data element in the [EMAIL PROTECTED] DataBuffer}, and each data element contains
* samples for one pixel only.
*
* @author Rolf W. Rasmussen ([EMAIL PROTECTED])
*/
public class SinglePixelPackedSampleModel extends SampleModel
{
private int scanlineStride;
private int[] bitMasks;
private int[] bitOffsets;
private int[] sampleSize;
@@ -139,38 +138,49 @@
sizes here by passing these from the current instance to a
special private constructor. */
return new SinglePixelPackedSampleModel(dataType, w, h, bitMasks);
}
/**
* Creates a DataBuffer for holding pixel data in the format and
* layout described by this SampleModel. The returned buffer will
* consist of one single bank.
*
* @return The data buffer.
*/
public DataBuffer createDataBuffer()
{
- int size;
-
// We can save (scanlineStride - width) pixels at the very end of
// the buffer. The Sun reference implementation (J2SE 1.3.1 and
// 1.4.1_01) seems to do this; tested with Mauve test code.
- size = scanlineStride * (height - 1) + width;
+ int size = scanlineStride * (height - 1) + width;
- return Buffers.createBuffer(getDataType(), size);
+ DataBuffer buffer = null;
+ switch (getTransferType())
+ {
+ case DataBuffer.TYPE_BYTE:
+ buffer = new DataBufferByte(size);
+ break;
+ case DataBuffer.TYPE_USHORT:
+ buffer = new DataBufferUShort(size);
+ break;
+ case DataBuffer.TYPE_INT:
+ buffer = new DataBufferInt(size);
+ break;
+ }
+ return buffer;
}
/**
* Returns an array containing the size (in bits) for each band accessed by
* the <code>SampleModel</code>.
*
* @return An array.
*
* @see #getSampleSize(int)
*/
public int[] getSampleSize()
{
return (int[]) sampleSize.clone();
}