본문 바로가기

언어/delphi

TPaingBox Canvas to Bitmap

출처: http://delphidabbler.com/tips/152


How to save the canvas of a TPaintBox to a .bmp file


var
  Bitmap: TBitmap;
  Source: TRect;
  Dest: TRect;
begin
  Bitmap := TBitmap.Create;
  try
    with Bitmap do
    begin
      Width := MyPaintBox.Width;
      Height := MyPaintBox.Height;
      Dest := Rect(0, 0, Width, Height);
    end;
    with MyPaintBox do
      Source := Rect(0, 0, Width, Height);
      Bitmap.Canvas.CopyRect(Dest, MyPaintBox.Canvas, Source);
      Bitmap.SaveToFile('MYFILE.BMP');
  finally
    Bitmap.Free;
  end;
end;

'언어 > delphi' 카테고리의 다른 글

델파이에서 동적으로 Package (bpl) 이용하기 (MDI Child)  (0) 2018.04.22
Package의 폼을 메인 폼으로  (0) 2018.04.22
ZXing.Delphi (Reading QRCode)  (0) 2018.03.30
Delphi QR Code Generator(zxing)  (0) 2018.03.28
퀀텀그리드  (0) 2017.03.01