This patch (committed) fixes a couple more problems in the MultiPixelPackedSampleModel class:

2006-07-14  David Gilbert  <[EMAIL PROTECTED]>

        * java/awt/image/MultiPixelPackedSampleModel.java
        (getSampleSize()): Return a copy of the array,
        (getTransferType()): New method override.

I have written Mauve tests for these.

Regards,

Dave
Index: java/awt/image/MultiPixelPackedSampleModel.java
===================================================================
RCS file: 
/sources/classpath/classpath/java/awt/image/MultiPixelPackedSampleModel.java,v
retrieving revision 1.9
diff -u -r1.9 MultiPixelPackedSampleModel.java
--- java/awt/image/MultiPixelPackedSampleModel.java     14 Jul 2006 11:04:42 
-0000      1.9
+++ java/awt/image/MultiPixelPackedSampleModel.java     14 Jul 2006 12:45:07 
-0000
@@ -152,11 +152,32 @@
     return 1;
   }
 
+  /**
+   * Returns an array containing the size (in bits) of the samples in each 
+   * band.  The <code>MultiPixelPackedSampleModel</code> class supports only
+   * one band, so this method returns an array with length <code>1</code>. 
+   * 
+   * @return An array containing the size (in bits) of the samples in band 
zero. 
+   *     
+   * @see #getSampleSize(int)
+   */
   public int[] getSampleSize()
   {
-    return sampleSize;
+    return (int[]) sampleSize.clone();
   }
   
+  /**
+   * Returns the size of the samples in the specified band.  Note that the
+   * <code>MultiPixelPackedSampleModel</code> supports only one band -- this
+   * method ignored the <code>band</code> argument, and always returns the size
+   * of band zero.
+   * 
+   * @param band  the band (this parameter is ignored).
+   * 
+   * @return The size of the samples in band zero.
+   * 
+   * @see #getSampleSize()
+   */
   public int getSampleSize(int band)
   {
     return sampleSize[0];
@@ -186,6 +207,26 @@
   {
     return numberOfBits;
   }
+  
+  /**
+   * Returns the transfer type, which is one of the following (depending on
+   * the number of bits per sample for this model):
+   * <ul>
+   *   <li>[EMAIL PROTECTED] DataBuffer#TYPE_BYTE};</li>
+   *   <li>[EMAIL PROTECTED] DataBuffer#TYPE_USHORT};</li>
+   *   <li>[EMAIL PROTECTED] DataBuffer#TYPE_INT};</li>
+   * </ul>
+   * 
+   * @return The transfer type.
+   */
+  public int getTransferType()
+  {
+    if (numberOfBits <= DataBuffer.getDataTypeSize(DataBuffer.TYPE_BYTE))
+      return DataBuffer.TYPE_BYTE;
+    else if (numberOfBits <= 
DataBuffer.getDataTypeSize(DataBuffer.TYPE_USHORT))
+      return DataBuffer.TYPE_USHORT;
+    return DataBuffer.TYPE_INT;
+  }
 
   /**
    * Normally this method returns a sample model for accessing a subset of

Reply via email to