- Timestamp:
- Apr 17, 2019, 12:58:41 AM (5 years ago)
- Location:
- GraphicTest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 8 8 GraphicTest.lps 9 9 GraphicTest.dbg 10 heaptrclog.trc
-
- Property svn:ignore
-
GraphicTest/Packages/bgrabitmap/bgracompressablebitmap.pas
r494 r521 47 47 public 48 48 CompressionLevel: Tcompressionlevel; 49 constructor Create; 50 constructor Create(Source: TBGRABitmap); 49 constructor Create; overload; 50 constructor Create(Source: TBGRABitmap); overload; 51 51 function GetBitmap: TBGRABitmap; 52 52 53 53 //call Compress as many times as necessary 54 54 //when it returns false, it means that … … 69 69 implementation 70 70 71 uses BGRAUTF8; 72 71 73 // size of each chunk treated by Compress function 72 74 const maxPartSize = 524288; … … 153 155 154 156 comp := Tcompressionstream.Create(CompressionLevel,FCompressedDataArray[high(FCompressedDataArray)],true); 155 comp.write(partSize,sizeof(partSize));157 LEWriteLongint(comp, partSize); 156 158 comp.CopyFrom(FUncompressedData,partSize); 157 159 comp.Free; … … 163 165 end; 164 166 165 {$hints off}166 function WinReadLongint(Stream: TStream): longint;167 begin168 stream.Read(Result, sizeof(Result));169 Result := LEtoN(Result);170 end;171 {$hints on}172 173 procedure WinWriteLongint(Stream: TStream; AValue: LongInt);174 begin175 AValue := NtoLE(AValue);176 stream.Write(AValue, sizeof(AValue));177 end;178 179 167 procedure TBGRACompressableBitmap.WriteToStream(AStream: TStream); 180 168 var i:integer; … … 182 170 repeat 183 171 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)); 187 175 AStream.Write(FCaption[1],length(FCaption)); 188 176 if (FWidth=0) or (FHeight = 0) then exit; 189 177 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)); 197 185 for i := 0 to high(FCompressedDataArray) do 198 186 begin 199 WinWriteLongint(AStream,FCompressedDataArray[i].Size);187 LEWriteLongint(AStream,FCompressedDataArray[i].Size); 200 188 FCompressedDataArray[i].Position := 0; 201 189 AStream.CopyFrom(FCompressedDataArray[i],FCompressedDataArray[i].Size); … … 207 195 begin 208 196 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)); 212 200 AStream.Read(FCaption[1],length(FCaption)); 213 201 if (FWidth=0) or (FHeight = 0) then … … 217 205 end; 218 206 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)); 226 214 for i := 0 to high(FCompressedDataArray) do 227 215 begin 228 size := WinReadLongint(AStream);216 size := LEReadLongint(AStream); 229 217 FCompressedDataArray[i] := TMemoryStream.Create; 230 218 FCompressedDataArray[i].CopyFrom(AStream,size); … … 246 234 FCompressedDataArray[i].Position := 0; 247 235 decomp := Tdecompressionstream.Create(FCompressedDataArray[i],true); 248 {$hints off} 249 decomp.read(partSize,sizeof(partSize)); 250 {$hints on} 236 partSize := LEReadLongint(decomp); 251 237 FUncompressedData.CopyFrom(decomp,partSize); 252 238 decomp.Free;
Note:
See TracChangeset
for help on using the changeset viewer.