LoadFromFile (Delphi)
From RAD Studio Code Examples
Language:
Description
This example uses a button on a form and creates two bitmaps dynamically. One bitmap is monochrome, which means all nonwhite colors become black. The bitmap file path is relative to the Debug directory.
Code
procedure TForm1.Button1Click(Sender: TObject); var BitMap1,BitMap2 : TBitMap; MyFormat : Word; begin BitMap2 := TBitMap.Create; BitMap1 := TBitMap.Create; try BitMap1.LoadFromFile('factory.bmp'); BitMap2.Assign(BitMap1); // Copy BitMap1 into BitMap2. BitMap2.Dormant; // Free up GDI resources. BitMap2.FreeImage; // Free up Memory. Canvas.Draw(20,20,BitMap2); // Note that previous calls do not lose the image. BitMap2.Monochrome := true; Canvas.Draw(80,80,BitMap2); BitMap2.ReleaseHandle; // This will actually lose the bitmap. finally BitMap1.Free; BitMap2.Free; end; end;
Uses
- Vcl.Graphics.TBitmap.Assign ( fr | de | ja )
- Vcl.Graphics.TBitmap.Dormant ( fr | de | ja )
- Vcl.Graphics.TBitmap.FreeImage ( fr | de | ja )
- Vcl.Graphics.TBitmap.Monochrome ( fr | de | ja )
- Vcl.Graphics.TBitmap.ReleaseHandle ( fr | de | ja )
- Vcl.Graphics.TGraphic.LoadFromFile ( fr | de | ja )