Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ExtCtrls, PNGImage;
- type
- TForm1 = class(TForm)
- PaintBox1: TPaintBox;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure PaintBox1Paint(Sender: TObject);
- private
- FBitmap: TBitmap;
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- var
- PNGImage: TPNGImage;
- begin
- FBitmap := TBitmap.Create;
- PNGImage := TPNGImage.Create;
- try
- PNGImage.LoadFromFile('C:\SomeFile.png');
- FBitmap.Assign(PNGImage);
- finally
- PNGImage.Free;
- end;
- end;
- procedure TForm1.FormDestroy(Sender: TObject);
- begin
- FBitmap.Free;
- end;
- procedure TForm1.PaintBox1Paint(Sender: TObject);
- begin
- // 128 in the fourth parameter is an example opacity value; it can be the value
- // in the range of 0 to 255, where 255 is fully opaque rendering
- PaintBox1.Canvas.Draw(0, 0, FBitmap, 128);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment