Recent

Author Topic: Copy stretched image with TCanvas.StretchDraw  (Read 7643 times)

hosune7845

  • Full Member
  • ***
  • Posts: 159
Copy stretched image with TCanvas.StretchDraw
« on: May 16, 2016, 08:19:57 am »
Hi.

I tried to copy my stretched image to TBitmap.

Drawing stretched image is fine. But no image is copied to TBitmap with StretchDraw.

Here's my code :

Code: Pascal  [Select][+][-]
  1. var
  2.   Bitmap: TBitmap;
  3. begin
  4.   Bitmap := TBitmap.Create;
  5.   Bitmap.PixelFormat := pf32bit;
  6.   Bitmap.SetSize(SrcImage.Width, SrcImage.Height); //SrcImage is stretched image
  7.   Bitmap.TranasparentColor := clGreen;
  8.   Bitmap.Canvas.Clear;
  9.   Bitmap.Canvas.StretchDraw(Rect(0, 0, SrcImage.Width, SrcImage.Height), SrcImage.Picture.Graphic);
  10. end;
  11.  

Any idea?

balazsszekely

  • Guest
Re: Copy stretched image with TCanvas.StretchDraw
« Reply #1 on: May 16, 2016, 09:50:18 am »
Your code works fine under win32/win64/Qt, on the other hand to make it work under GTK2, you have to comment out the following line:
//Bitmap.PixelFormat := pf32bit;
« Last Edit: May 16, 2016, 10:24:03 am by GetMem »

hosune7845

  • Full Member
  • ***
  • Posts: 159
Re: Copy stretched image with TCanvas.StretchDraw
« Reply #2 on: May 17, 2016, 02:00:51 am »
Your code works fine under win32/win64/Qt, on the other hand to make it work under GTK2, you have to comment out the following line:
//Bitmap.PixelFormat := pf32bit;

I use Lazarus on Ubuntu x32 for arm-linux.

I ran test with "//Bitmap.PixelFormat := pf32bit;" but same issue.

Here's my code for drawing stretch image

Code: Pascal  [Select][+][-]
  1. begin
  2.   SrcImage.Stretch := True;
  3.   with SrcImage.Picture.Bitmap do
  4.   begin
  5.     SetSize(trunc(SrcImage.Width / 2), trunc(SrcImage.Height / 2));
  6.     TransparentColor := clGreen;
  7.     Canvas.Clear;
  8.     Canvas.TextOut(0,0,'TEST FOR STRETCH');  
  9.   end;
  10. end;
  11.  

 

TinyPortal © 2005-2018