Ignore:
Timestamp:
Apr 17, 2019, 12:58:41 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Propagate project build mode options to used packages.
  • Added: Check memory leaks using heaptrc.
  • Modified: Update BGRABitmap package.
Location:
GraphicTest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest

    • Property svn:ignore
      •  

        old new  
        88GraphicTest.lps
        99GraphicTest.dbg
         10heaptrclog.trc
  • GraphicTest/Packages/bgrabitmap/bgracompressablebitmap.pas

    r494 r521  
    4747   public
    4848     CompressionLevel: Tcompressionlevel;
    49      constructor Create;
    50      constructor Create(Source: TBGRABitmap);
     49     constructor Create; overload;
     50     constructor Create(Source: TBGRABitmap); overload;
    5151     function GetBitmap: TBGRABitmap;
    52      
     52
    5353     //call Compress as many times as necessary
    5454     //when it returns false, it means that
     
    6969implementation
    7070
     71uses BGRAUTF8;
     72
    7173// size of each chunk treated by Compress function
    7274const maxPartSize = 524288;
     
    153155
    154156    comp := Tcompressionstream.Create(CompressionLevel,FCompressedDataArray[high(FCompressedDataArray)],true);
    155     comp.write(partSize,sizeof(partSize));
     157    LEWriteLongint(comp, partSize);
    156158    comp.CopyFrom(FUncompressedData,partSize);
    157159    comp.Free;
     
    163165end;
    164166
    165 {$hints off}
    166 function WinReadLongint(Stream: TStream): longint;
    167 begin
    168   stream.Read(Result, sizeof(Result));
    169   Result := LEtoN(Result);
    170 end;
    171 {$hints on}
    172 
    173 procedure WinWriteLongint(Stream: TStream; AValue: LongInt);
    174 begin
    175   AValue := NtoLE(AValue);
    176   stream.Write(AValue, sizeof(AValue));
    177 end;
    178 
    179167procedure TBGRACompressableBitmap.WriteToStream(AStream: TStream);
    180168var i:integer;
     
    182170  repeat
    183171  until not Compress;
    184   WinWriteLongint(AStream,FWidth);
    185   WinWriteLongint(AStream,FHeight);
    186   WinWriteLongint(AStream,length(FCaption));
     172  LEWriteLongint(AStream,FWidth);
     173  LEWriteLongint(AStream,FHeight);
     174  LEWriteLongint(AStream,length(FCaption));
    187175  AStream.Write(FCaption[1],length(FCaption));
    188176  if (FWidth=0) or (FHeight = 0) then exit;
    189177
    190   WinWriteLongint(AStream,FBounds.Left);
    191   WinWriteLongint(AStream,FBounds.Top);
    192   WinWriteLongint(AStream,FBounds.Right);
    193   WinWriteLongint(AStream,FBounds.Bottom);
    194   WinWriteLongint(AStream,ord(FLineOrder));
    195 
    196   WinWriteLongint(AStream,length(FCompressedDataArray));
     178  LEWriteLongint(AStream,FBounds.Left);
     179  LEWriteLongint(AStream,FBounds.Top);
     180  LEWriteLongint(AStream,FBounds.Right);
     181  LEWriteLongint(AStream,FBounds.Bottom);
     182  LEWriteLongint(AStream,ord(FLineOrder));
     183
     184  LEWriteLongint(AStream,length(FCompressedDataArray));
    197185  for i := 0 to high(FCompressedDataArray) do
    198186  begin
    199     WinWriteLongint(AStream,FCompressedDataArray[i].Size);
     187    LEWriteLongint(AStream,FCompressedDataArray[i].Size);
    200188    FCompressedDataArray[i].Position := 0;
    201189    AStream.CopyFrom(FCompressedDataArray[i],FCompressedDataArray[i].Size);
     
    207195begin
    208196  FreeData;
    209   FWidth := WinReadLongint(AStream);
    210   FHeight := WinReadLongint(AStream);
    211   setlength(FCaption,WinReadLongint(AStream));
     197  FWidth := LEReadLongint(AStream);
     198  FHeight := LEReadLongint(AStream);
     199  setlength(FCaption,LEReadLongint(AStream));
    212200  AStream.Read(FCaption[1],length(FCaption));
    213201  if (FWidth=0) or (FHeight = 0) then
     
    217205  end;
    218206
    219   FBounds.Left := WinReadLongint(AStream);
    220   FBounds.Top := WinReadLongint(AStream);
    221   FBounds.Right := WinReadLongint(AStream);
    222   FBounds.Bottom := WinReadLongint(AStream);
    223   FLineOrder := TRawImageLineOrder(WinReadLongint(AStream));
    224 
    225   setlength(FCompressedDataArray,WinReadLongint(AStream));
     207  FBounds.Left := LEReadLongint(AStream);
     208  FBounds.Top := LEReadLongint(AStream);
     209  FBounds.Right := LEReadLongint(AStream);
     210  FBounds.Bottom := LEReadLongint(AStream);
     211  FLineOrder := TRawImageLineOrder(LEReadLongint(AStream));
     212
     213  setlength(FCompressedDataArray,LEReadLongint(AStream));
    226214  for i := 0 to high(FCompressedDataArray) do
    227215  begin
    228     size := WinReadLongint(AStream);
     216    size := LEReadLongint(AStream);
    229217    FCompressedDataArray[i] := TMemoryStream.Create;
    230218    FCompressedDataArray[i].CopyFrom(AStream,size);
     
    246234    FCompressedDataArray[i].Position := 0;
    247235    decomp := Tdecompressionstream.Create(FCompressedDataArray[i],true);
    248     {$hints off}
    249     decomp.read(partSize,sizeof(partSize));
    250     {$hints on}
     236    partSize := LEReadLongint(decomp);
    251237    FUncompressedData.CopyFrom(decomp,partSize);
    252238    decomp.Free;
Note: See TracChangeset for help on using the changeset viewer.