TGraphic (Delphi)
Description
This example demonstrates the use of some methods and properties available for TBitmap and TGraphic objects.
Code
procedure TMainForm.btCompareClick(Sender: TObject);
begin
{ Compare the contents of two graphics }
if MyImage1.Picture.Graphic.Equals(MyImage2.Picture.Graphic) then
Memo1.Lines.Add('Same image')
else
Memo1.Lines.Add('Different images');
end;
procedure TMainForm.btLoadClick(Sender: TObject);
begin
OpenPictureDialog1.Execute();
{ Load a picture from a file }
MyImage2.Picture.LoadFromFile(String(OpenPictureDialog1.FileName));
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
{ Change the AlphaFormat property }
MyImage1.Picture.Bitmap.AlphaFormat := afPremultiplied;
{ Check whether the graphic supports partial transparency.
This is a read-only property }
if (MyImage1.Picture.Graphic.SupportsPartialTransparency) then
Memo1.Lines.Add('The graphic supports partial transparency')
else
Memo1.Lines.Add('The graphic does not support partial transparency');
end;
Uses
- Vcl.Graphics.TBitmap.AlphaFormat ( fr | de | ja )
- Vcl.Graphics.TGraphic.Equals ( fr | de | ja )
- Vcl.Graphics.TGraphic.SupportsPartialTransparency ( fr | de | ja )
- Vcl.Graphics.TPicture.LoadFromFile ( fr | de | ja )