< prev index next >

src/java.desktop/share/classes/sun/awt/image/BytePackedRaster.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -27,11 +27,10 @@
 import java.awt.image.Raster;
 import java.awt.image.WritableRaster;
 import java.awt.image.RasterFormatException;
 import java.awt.image.SampleModel;
 import java.awt.image.MultiPixelPackedSampleModel;
-import java.awt.image.DataBuffer;
 import java.awt.image.DataBufferByte;
 import java.awt.Rectangle;
 import java.awt.Point;
 
 /**

@@ -90,11 +89,11 @@
      * @param origin          The Point that specified the origin.
      */
     public BytePackedRaster(SampleModel sampleModel,
                             Point origin) {
         this(sampleModel,
-             sampleModel.createDataBuffer(),
+             (DataBufferByte)sampleModel.createDataBuffer(),
              new Rectangle(origin.x,
                            origin.y,
                            sampleModel.getWidth(),
                            sampleModel.getHeight()),
              origin,

@@ -106,15 +105,15 @@
      * and DataBuffer.  The Raster's upper left corner is origin and
      * it is the same size as the SampleModel.  The DataBuffer is not
      * initialized and must be a DataBufferByte compatible with SampleModel.
      * SampleModel must be of type MultiPixelPackedSampleModel.
      * @param sampleModel     The SampleModel that specifies the layout.
-     * @param dataBuffer      The DataBufferShort that contains the image data.
+     * @param dataBuffer      The DataBufferByte that contains the image data.
      * @param origin          The Point that specifies the origin.
      */
     public BytePackedRaster(SampleModel sampleModel,
-                            DataBuffer dataBuffer,
+                            DataBufferByte dataBuffer,
                             Point origin) {
         this(sampleModel,
              dataBuffer,
              new Rectangle(origin.x,
                            origin.y,

@@ -135,39 +134,34 @@
      * 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 dataBuffer      The DataBufferByte 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.
      *
      * @exception RasterFormatException if the parameters do not conform
      * to requirements of this Raster type.
      */
     public BytePackedRaster(SampleModel sampleModel,
-                            DataBuffer dataBuffer,
+                            DataBufferByte dataBuffer,
                             Rectangle aRegion,
                             Point origin,
                             BytePackedRaster parent){
         super(sampleModel,dataBuffer,aRegion,origin, parent);
         this.maxX = minX + width;
         this.maxY = minY + height;
 
-        if (!(dataBuffer instanceof DataBufferByte)) {
-           throw new RasterFormatException("BytePackedRasters must have" +
-                "byte DataBuffers");
-        }
-        DataBufferByte dbb = (DataBufferByte)dataBuffer;
-        this.data = stealData(dbb, 0);
-        if (dbb.getNumBanks() != 1) {
+        this.data = stealData(dataBuffer, 0);
+        if (dataBuffer.getNumBanks() != 1) {
             throw new
                 RasterFormatException("DataBuffer for BytePackedRasters"+
                                       " must only have 1 bank.");
         }
-        int dbOffset = dbb.getOffset();
+        int dbOffset = dataBuffer.getOffset();
 
         if (sampleModel instanceof MultiPixelPackedSampleModel) {
             MultiPixelPackedSampleModel mppsm =
                 (MultiPixelPackedSampleModel)sampleModel;
             this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;

@@ -1320,11 +1314,11 @@
 
         int deltaX = x0 - x;
         int deltaY = y0 - y;
 
         return new BytePackedRaster(sm,
-                                    dataBuffer,
+                                    (DataBufferByte)dataBuffer,
                                     new Rectangle(x0, y0, width, height),
                                     new Point(sampleModelTranslateX+deltaX,
                                               sampleModelTranslateY+deltaY),
                                     this);
     }
< prev index next >