diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2015-09-02 10:14:12 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2015-09-02 10:14:12 +0100 |
commit | f44e5ce188233f475622cb0116411257bfbc0a84 (patch) | |
tree | d5c7233545ce07d0185e22dcb0ca3cd0e35186d0 /docview | |
parent | 772b417cab82318142e0829ba51a71cc21a594a6 (diff) | |
download | fpGUI-f44e5ce188233f475622cb0116411257bfbc0a84.tar.xz |
docview: finally fixed the broken INF image support.
It only took 6 years. ;-)
Diffstat (limited to 'docview')
-rw-r--r-- | docview/src/HelpBitmap.pas | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/docview/src/HelpBitmap.pas b/docview/src/HelpBitmap.pas index 28b04d68..b5464cbf 100644 --- a/docview/src/HelpBitmap.pas +++ b/docview/src/HelpBitmap.pas @@ -282,10 +282,14 @@ var ptr: PByte; i: integer; img: TfpgImage; + {$IFDEF LZW_DEBUG} + s: TFileStream; + {$ENDIF} begin BitmapOutputPointer := nil; BitmapData := nil; ptr := nil; + lastOutByte := $0; // Allocate memory to store the bitmap BitmapData := GetMem( TotalSize ); @@ -309,6 +313,9 @@ begin case Block._CompressionType of 0,1: // uncompressed (I'm not sure about 1) begin + {$IFDEF LZW_DEBUG} + writeln('Uncompressed image type'); + {$ENDIF} MemCopy( Block._Data^, BitmapOutputPointer^, Block._Size ); BytesWrittenFromBlock := Block._Size; inc( BytesWritten, BytesWrittenFromBlock ); @@ -316,6 +323,9 @@ begin 2: // LZW compression begin + {$IFDEF LZW_DEBUG} + writeln('LZW compressed image type'); + {$ENDIF} LZWDecompressBlock( Block._Data, Block._Size, BitmapOutputPointer, @@ -353,35 +363,25 @@ begin > BitmapData + TotalSize ) then assert( false ); -{ NOTE: This doesn't seem right. It moves the pointer so later the moving of data to - ImageData will be wrong! } -// inc( BitmapOutputPointer, BytesWrittenFromBlock ); TPersistentObjectState + inc( BitmapOutputPointer, BytesWrittenFromBlock ); end; - i := TotalSize + SizeOf(_Header) + GetPaletteSize; - img := CreateImage_BMP(BitmapData, i); - - AllocateImage(32, _Header.cx, _Header.cy); - {$IFDEF LZW_DEBUG} - writeln('Width = ', Width); - writeln('Height = ', Height); - writeln('ImageDataSize = ', ImageDataSize); - writeln('------------- START -------------'); - for i := 1 to ImageDataSize do - begin - write(HexStr(BitmapOutputPointer[i-1],2)+' '); - if (i mod 16 = 0) then - writeln('') - else if (i mod 4 = 0) then - write (' | '); - end; - Writeln(''); - writeln('------------- END -------------'); + // write the decompressed image to a .BMP file to verify it is okay + s := TFileStream.Create(Format('/tmp/image_%d.bmp', [TotalSize]), fmCreate); + BitmapData[0] := Byte('B'); + s.WriteBuffer(BitmapData^, TotalSize); + s.Destroy; + BitmapData[0] := Byte('b'); {$ENDIF} -// Move(BitmapOutputPointer^, ImageData^, ImageDataSize); - Move(img.ImageData^, self.ImageData^, img.ImageDataSize); + img := CreateImage_BMP(BitmapData, TotalSize); + + FreeImage; // just as a precaution + AllocateImage(32, _Header.cx, _Header.cy); + // copy imagedata from the img instance to our THelpBitmap.ImageData + MemCopy(img.ImageData^, self.ImageData^, img.ImageDataSize); + UpdateImage; img.Free; |