src/java.desktop/share/classes/java/awt/image/SampleModel.java

Print this page




  82 {
  83 
  84     /** Width in pixels of the region of image data that this SampleModel
  85      *  describes.
  86      */
  87     protected int width;
  88 
  89     /** Height in pixels of the region of image data that this SampleModel
  90      *  describes.
  91      */
  92     protected int height;
  93 
  94     /** Number of bands of the image data that this SampleModel describes. */
  95     protected int numBands;
  96 
  97     /** Data type of the DataBuffer storing the pixel data.
  98      *  @see java.awt.image.DataBuffer
  99      */
 100     protected int dataType;
 101 
 102     static private native void initIDs();
 103     static {
 104         ColorModel.loadLibraries();
 105         initIDs();
 106     }
 107 
 108     /**
 109      * Constructs a SampleModel with the specified parameters.
 110      * @param dataType  The data type of the DataBuffer storing the pixel data.
 111      * @param w         The width (in pixels) of the region of image data.
 112      * @param h         The height (in pixels) of the region of image data.
 113      * @param numBands  The number of bands of the image data.
 114      * @throws IllegalArgumentException if <code>w</code> or <code>h</code>
 115      *         is not greater than 0
 116      * @throws IllegalArgumentException if the product of <code>w</code>
 117      *         and <code>h</code> is greater than
 118      *         <code>Integer.MAX_VALUE</code>
 119      * @throws IllegalArgumentException if <code>dataType</code> is not
 120      *         one of the supported data types
 121      */
 122     public SampleModel(int dataType, int w, int h, int numBands)


 136              dataType != DataBuffer.TYPE_UNDEFINED))
 137         {
 138             throw new IllegalArgumentException("Unsupported dataType: "+
 139                                                dataType);
 140         }
 141 
 142         if (numBands <= 0) {
 143             throw new IllegalArgumentException("Number of bands must be > 0");
 144         }
 145 
 146         this.dataType = dataType;
 147         this.width = w;
 148         this.height = h;
 149         this.numBands = numBands;
 150     }
 151 
 152     /** Returns the width in pixels.
 153      *  @return the width in pixels of the region of image data
 154      *          that this <code>SampleModel</code> describes.
 155      */
 156     final public int getWidth() {
 157          return width;
 158     }
 159 
 160     /** Returns the height in pixels.
 161      *  @return the height in pixels of the region of image data
 162      *          that this <code>SampleModel</code> describes.
 163      */
 164     final public int getHeight() {
 165          return height;
 166     }
 167 
 168     /** Returns the total number of bands of image data.
 169      *  @return the number of bands of image data that this
 170      *          <code>SampleModel</code> describes.
 171      */
 172     final public int getNumBands() {
 173          return numBands;
 174     }
 175 
 176     /** Returns the number of data elements needed to transfer a pixel
 177      *  via the getDataElements and setDataElements methods.  When pixels
 178      *  are transferred via these methods, they may be transferred in a
 179      *  packed or unpacked format, depending on the implementation of the
 180      *  SampleModel.  Using these methods, pixels are transferred as an
 181      *  array of getNumDataElements() elements of a primitive type given
 182      *  by getTransferType().  The TransferType may or may not be the same
 183      *  as the storage DataType.
 184      *  @return the number of data elements.
 185      *  @see #getDataElements(int, int, Object, DataBuffer)
 186      *  @see #getDataElements(int, int, int, int, Object, DataBuffer)
 187      *  @see #setDataElements(int, int, Object, DataBuffer)
 188      *  @see #setDataElements(int, int, int, int, Object, DataBuffer)
 189      *  @see #getTransferType
 190      */
 191     public abstract int getNumDataElements();
 192 
 193     /** Returns the data type of the DataBuffer storing the pixel data.
 194      *  @return the data type.
 195      */
 196     final public int getDataType() {
 197         return dataType;
 198     }
 199 
 200     /** Returns the TransferType used to transfer pixels via the
 201      *  getDataElements and setDataElements methods.  When pixels
 202      *  are transferred via these methods, they may be transferred in a
 203      *  packed or unpacked format, depending on the implementation of the
 204      *  SampleModel.  Using these methods, pixels are transferred as an
 205      *  array of getNumDataElements() elements of a primitive type given
 206      *  by getTransferType().  The TransferType may or may not be the same
 207      *  as the storage DataType.  The TransferType will be one of the types
 208      *  defined in DataBuffer.
 209      *  @return the transfer type.
 210      *  @see #getDataElements(int, int, Object, DataBuffer)
 211      *  @see #getDataElements(int, int, int, int, Object, DataBuffer)
 212      *  @see #setDataElements(int, int, Object, DataBuffer)
 213      *  @see #setDataElements(int, int, int, int, Object, DataBuffer)
 214      *  @see #getNumDataElements
 215      *  @see java.awt.image.DataBuffer
 216      */




  82 {
  83 
  84     /** Width in pixels of the region of image data that this SampleModel
  85      *  describes.
  86      */
  87     protected int width;
  88 
  89     /** Height in pixels of the region of image data that this SampleModel
  90      *  describes.
  91      */
  92     protected int height;
  93 
  94     /** Number of bands of the image data that this SampleModel describes. */
  95     protected int numBands;
  96 
  97     /** Data type of the DataBuffer storing the pixel data.
  98      *  @see java.awt.image.DataBuffer
  99      */
 100     protected int dataType;
 101 
 102     private static native void initIDs();
 103     static {
 104         ColorModel.loadLibraries();
 105         initIDs();
 106     }
 107 
 108     /**
 109      * Constructs a SampleModel with the specified parameters.
 110      * @param dataType  The data type of the DataBuffer storing the pixel data.
 111      * @param w         The width (in pixels) of the region of image data.
 112      * @param h         The height (in pixels) of the region of image data.
 113      * @param numBands  The number of bands of the image data.
 114      * @throws IllegalArgumentException if <code>w</code> or <code>h</code>
 115      *         is not greater than 0
 116      * @throws IllegalArgumentException if the product of <code>w</code>
 117      *         and <code>h</code> is greater than
 118      *         <code>Integer.MAX_VALUE</code>
 119      * @throws IllegalArgumentException if <code>dataType</code> is not
 120      *         one of the supported data types
 121      */
 122     public SampleModel(int dataType, int w, int h, int numBands)


 136              dataType != DataBuffer.TYPE_UNDEFINED))
 137         {
 138             throw new IllegalArgumentException("Unsupported dataType: "+
 139                                                dataType);
 140         }
 141 
 142         if (numBands <= 0) {
 143             throw new IllegalArgumentException("Number of bands must be > 0");
 144         }
 145 
 146         this.dataType = dataType;
 147         this.width = w;
 148         this.height = h;
 149         this.numBands = numBands;
 150     }
 151 
 152     /** Returns the width in pixels.
 153      *  @return the width in pixels of the region of image data
 154      *          that this <code>SampleModel</code> describes.
 155      */
 156     public final int getWidth() {
 157          return width;
 158     }
 159 
 160     /** Returns the height in pixels.
 161      *  @return the height in pixels of the region of image data
 162      *          that this <code>SampleModel</code> describes.
 163      */
 164     public final int getHeight() {
 165          return height;
 166     }
 167 
 168     /** Returns the total number of bands of image data.
 169      *  @return the number of bands of image data that this
 170      *          <code>SampleModel</code> describes.
 171      */
 172     public final int getNumBands() {
 173          return numBands;
 174     }
 175 
 176     /** Returns the number of data elements needed to transfer a pixel
 177      *  via the getDataElements and setDataElements methods.  When pixels
 178      *  are transferred via these methods, they may be transferred in a
 179      *  packed or unpacked format, depending on the implementation of the
 180      *  SampleModel.  Using these methods, pixels are transferred as an
 181      *  array of getNumDataElements() elements of a primitive type given
 182      *  by getTransferType().  The TransferType may or may not be the same
 183      *  as the storage DataType.
 184      *  @return the number of data elements.
 185      *  @see #getDataElements(int, int, Object, DataBuffer)
 186      *  @see #getDataElements(int, int, int, int, Object, DataBuffer)
 187      *  @see #setDataElements(int, int, Object, DataBuffer)
 188      *  @see #setDataElements(int, int, int, int, Object, DataBuffer)
 189      *  @see #getTransferType
 190      */
 191     public abstract int getNumDataElements();
 192 
 193     /** Returns the data type of the DataBuffer storing the pixel data.
 194      *  @return the data type.
 195      */
 196     public final int getDataType() {
 197         return dataType;
 198     }
 199 
 200     /** Returns the TransferType used to transfer pixels via the
 201      *  getDataElements and setDataElements methods.  When pixels
 202      *  are transferred via these methods, they may be transferred in a
 203      *  packed or unpacked format, depending on the implementation of the
 204      *  SampleModel.  Using these methods, pixels are transferred as an
 205      *  array of getNumDataElements() elements of a primitive type given
 206      *  by getTransferType().  The TransferType may or may not be the same
 207      *  as the storage DataType.  The TransferType will be one of the types
 208      *  defined in DataBuffer.
 209      *  @return the transfer type.
 210      *  @see #getDataElements(int, int, Object, DataBuffer)
 211      *  @see #getDataElements(int, int, int, int, Object, DataBuffer)
 212      *  @see #setDataElements(int, int, Object, DataBuffer)
 213      *  @see #setDataElements(int, int, int, int, Object, DataBuffer)
 214      *  @see #getNumDataElements
 215      *  @see java.awt.image.DataBuffer
 216      */