anchor.diff:           > 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
  -  end;
  -
  -  i := TotalSize + SizeOf(_Header) + GetPaletteSize;
  -  img := CreateImage_BMP(BitmapData, i);
  -
  +    inc( BitmapOutputPointer, BytesWrittenFromBlock );
  +  end;
  +
  +  {$IFDEF LZW_DEBUG}
  +  // 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}
  +
  +  img := CreateImage_BMP(BitmapData, TotalSize);
  +
  +  FreeImage;  // just as a precaution
     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 -------------');
  -  {$ENDIF}
  -
  -//  Move(BitmapOutputPointer^, ImageData^, ImageDataSize);
  -  Move(img.ImageData^, self.ImageData^, img.ImageDataSize);
  +  // copy imagedata from the img instance to our THelpBitmap.ImageData
  +  MemCopy(img.ImageData^, self.ImageData^, img.ImageDataSize);
  +
     UpdateImage;
     img.Free;
   
  
positive.code:   ptr: PByte;
    i: integer;
    img: TfpgImage;
  begin
    BitmapOutputPointer := nil;
    BitmapData := nil;
    ptr := nil;
  
    // Allocate memory to store the bitmap
    BitmapData := GetMem( TotalSize );
  
negative.code: 
        2: // LZW compression
        begin
          {$IFDEF LZW_DEBUG}
          writeln('LZW compressed image type');
          {$ENDIF}
          LZWDecompressBlock( Block._Data,
                              Block._Size,
                              BitmapOutputPointer,
  