Changeset 266 for branches/highdpi/Packages/CevoComponents/ScreenTools.pas
- Timestamp:
- Jun 26, 2020, 1:13:34 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/ScreenTools.pas
r265 r266 406 406 jtex := TDpiJpegImage.Create; 407 407 try 408 jtex.LoadFromFile(Path); 409 except 410 Result := False; 411 end; 412 if Result then 413 begin 414 if Options and gfNoGamma = 0 then 415 bmp.PixelFormat := pf24bit; 416 Bmp.SetSize(jtex.Width, jtex.Height); 417 Bmp.Canvas.Draw(0, 0, jtex); 418 end; 419 jtex.Free; 408 try 409 jtex.LoadFromFile(Path); 410 except 411 Result := False; 412 end; 413 if Result then 414 begin 415 if Options and gfNoGamma = 0 then 416 bmp.PixelFormat := pf24bit; 417 Bmp.SetSize(jtex.Width, jtex.Height); 418 Bmp.Canvas.Draw(0, 0, jtex); 419 end; 420 finally 421 FreeAndNil(jtex); 422 end; 420 423 end 421 424 else 422 425 if ExtractFileExt(Path) = '.png' then begin 423 426 Png := TDpiPortableNetworkGraphic.Create; 424 Png.PixelFormat := Bmp.PixelFormat;425 427 try 426 Png.LoadFromFile(Path); 427 except 428 Result := False; 429 end; 430 if Result then 431 begin 432 if Options and gfNoGamma = 0 then 433 bmp.PixelFormat := pf24bit; 434 bmp.SetSize(Png.Width, Png.Height); 435 if (Png.RawImage.Description.Format = ricfGray) then 436 begin 437 // LCL doesn't support 8-bit colors properly. Use 24-bit instead. 438 Bmp.PixelFormat := pf24bit; 439 CopyGray8BitTo24bitBitmap(Bmp, Png); 440 end 441 else 442 Bmp.Canvas.draw(0, 0, Png); 443 end; 444 Png.Free; 445 end 446 else 428 Png.PixelFormat := Bmp.PixelFormat; 429 try 430 Png.LoadFromFile(Path); 431 except 432 Result := False; 433 end; 434 if Result then begin 435 if Options and gfNoGamma = 0 then 436 bmp.PixelFormat := pf24bit; 437 bmp.SetSize(Png.Width, Png.Height); 438 if (Png.RawImage.Description.Format = ricfGray) then 439 begin 440 // LCL doesn't support 8-bit colors properly. Use 24-bit instead. 441 Bmp.PixelFormat := pf24bit; 442 CopyGray8BitTo24bitBitmap(Bmp, Png); 443 end else 444 Bmp.Canvas.draw(0, 0, Png); 445 end; 446 finally 447 FreeAndNil(Png); 448 end; 449 end else 447 450 if ExtractFileExt(Path) = '.bmp' then begin 448 451 try … … 455 458 bmp.PixelFormat := pf24bit; 456 459 end; 457 end 458 else 460 end else 459 461 raise Exception.Create('Unsupported image file type ' + ExtractFileExt(Path)); 460 462 … … 1728 1730 RestoreResolution; 1729 1731 for I := 0 to nGrExt - 1 do begin 1730 GrExt[I].Data.Free;1731 GrExt[I].Mask.Free;1732 FreeAndNil(GrExt[I].Data); 1733 FreeAndNil(GrExt[I].Mask); 1732 1734 FreeMem(GrExt[I]); 1733 1735 end;
Note:
See TracChangeset
for help on using the changeset viewer.