@@ -23,6 +23,12 @@ UINT ReadUInt32(IStream *pStream) {
2323 return b[0 ] << 24 | b[1 ] << 16 | b[2 ] << 8 | b[3 ];
2424}
2525
26+ SHORT ReadInt16 (IStream *pStream) {
27+ BYTE b[2 ];
28+ ReadData (pStream, b, 2 );
29+ return b[0 ] << 8 | b[1 ];
30+ }
31+
2632USHORT ReadUInt16 (IStream *pStream) {
2733 BYTE b[2 ];
2834 ReadData (pStream, b, 2 );
@@ -104,8 +110,8 @@ HBITMAP GetPSDThumbnail(IStream* stream) {
104110 UINT layerAndMastInfoOffset = Tell (stream);
105111
106112 UINT layerInfoLength = ReadUInt32 (stream);
107- USHORT layerCount = ReadUInt16 (stream);
108- bool globalAlpha = layerAndMaskInfoLength < 0 ;
113+ SHORT layerCount = ReadInt16 (stream);
114+ bool globalAlpha = layerCount < 0 ;
109115
110116 Seek (stream, layerAndMastInfoOffset + layerAndMaskInfoLength, STREAM_SEEK_SET );
111117
@@ -168,13 +174,13 @@ HBITMAP GetPSDThumbnail(IStream* stream) {
168174
169175 for (int j = 0 ; j <= header; j++) {
170176 data[p] = value;
171- p = (p + step) ;
177+ p += step;
172178 }
173179 }
174180 else { // header < 128
175181 for (int j = 0 ; j <= header; j++) {
176182 data[p] = buffer[++i];
177- p = (p + step) ;
183+ p += step;
178184 }
179185 }
180186 }
@@ -188,11 +194,11 @@ HBITMAP GetPSDThumbnail(IStream* stream) {
188194
189195 if (width > height) {
190196 thumbWidth = 256 ;
191- thumbHeight = floor ( height * thumbWidth / width) ;
197+ thumbHeight = height * thumbWidth / width;
192198 }
193199 else {
194200 thumbHeight = 256 ;
195- thumbWidth = floor ( width * thumbHeight / height) ;
201+ thumbWidth = width * thumbHeight / height;
196202 }
197203
198204 BLENDFUNCTION fnc;
0 commit comments