@@ -1207,12 +1207,12 @@ private Object readFixedLengthFrame (RandomAccessFile rFile, int size) throws Ex
12071207 byte [] bPixels = null ;
12081208 int [] cPixels = null ;
12091209 short [] sPixels = null ;
1210- if (biBitCount <=8 || convertToGray ) {
1211- bPixels = new byte [dwWidth * biHeight ];
1212- pixels = bPixels ;
1213- } else if (biBitCount == 16 && dataCompression == NO_COMPRESSION ) {
1210+ if (biBitCount == 16 && dataCompression == NO_COMPRESSION ) {
12141211 sPixels = new short [dwWidth * biHeight ];
12151212 pixels = sPixels ;
1213+ } else if (biBitCount <=8 || convertToGray ) {
1214+ bPixels = new byte [dwWidth * biHeight ];
1215+ pixels = bPixels ;
12161216 } else {
12171217 cPixels = new int [dwWidth * biHeight ];
12181218 pixels = cPixels ;
@@ -1223,12 +1223,12 @@ private Object readFixedLengthFrame (RandomAccessFile rFile, int size) throws Ex
12231223 int offset = topDown ? 0 : (biHeight -1 )*dwWidth ;
12241224 int rawOffset = 0 ;
12251225 for (int i = biHeight - 1 ; i >= 0 ; i --) { //for all lines
1226- if (biBitCount <=8 || isPlanarFormat )
1226+ if (biBitCount ==16 && dataCompression == NO_COMPRESSION )
1227+ unpackShort (rawData , rawOffset , sPixels , offset , dwWidth );
1228+ else if (biBitCount <=8 || isPlanarFormat ) //planar&converToGray: read 1st plane (Y)
12271229 unpack8bit (rawData , rawOffset , bPixels , offset , dwWidth );
12281230 else if (convertToGray )
12291231 unpackGray (rawData , rawOffset , bPixels , offset , dwWidth );
1230- else if (biBitCount ==16 && dataCompression == NO_COMPRESSION )
1231- unpackShort (rawData , rawOffset , sPixels , offset , dwWidth );
12321232 else
12331233 unpack (rawData , rawOffset , cPixels , offset , dwWidth );
12341234 rawOffset += isPlanarFormat ? dwWidth : scanLineSize ;
0 commit comments