src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java

Print this page

        

@@ -106,10 +106,11 @@
     private static final int VERSION_5_XP_EMBEDDED = 18;
 
     // BMP variables
     private long bitmapFileSize;
     private long bitmapOffset;
+    private long bitmapStart;
     private long compression;
     private long imageSize;
     private byte palette[];
     private int imageType;
     private int numBands;

@@ -675,10 +676,12 @@
 
         // Reset to the start of bitmap; then jump to the
         //start of image data
         iis.reset();
         iis.skipBytes(bitmapOffset);
+        bitmapStart = iis.getStreamPosition();
+
         gotHeader = true;
     }
 
     public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
       throws IOException {

@@ -811,10 +814,12 @@
                 sdata = ((DataBufferUShort)raster.getDataBuffer()).getData();
             else if (sampleModel.getDataType() == DataBuffer.TYPE_INT)
                 idata = ((DataBufferInt)raster.getDataBuffer()).getData();
         }
 
+        iis.seek(bitmapStart);
+
         // There should only be one tile.
         switch(imageType) {
 
         case VERSION_2_1_BIT:
             // no compression