[fpc-devel] FPImage to LCL. How to do it?
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Feb 24 21:47:17 CET 2025
On 2/24/25 20:22, Giuliano Colla via fpc-devel wrote:
> I have an application where I need to rotate an image for displaying in
> an LCL image. The image is a clock face, the image to rotate is each of
> the hands.
> I can get the bitmap from the source LCL image, and copy the rectangle
> from the LCL image canvas to the FPImage canvas.
> I can rotate it, but I'm unable to copy back the resulting image to the
> LCL canvas, because I'm told that the TFPImageCanvas is an
> "incompatible type" with TCanvas.
If you have a FPImage canvas, then you should have a TFPCustomImage.
Preferably a LazIntfImage, preferably initialized to the same format as
the LCL widgetset.
uses ..., IntfGraphics, LCLType, LCLIntf;
var
LazImg: TLazIntfImage;
BitmapHnd, DummyHnd: HBITMAP;
LCLCanvas: TCanvas;
RotatedWidth, RotatedHeight, x, y: Integer;
begin
LCLCanvas:=Canvas;
RotatedWidth:=100;
RotatedHeight:=100;
x:=0;
y:=0;
// create a memory image
LazImg := TLazIntfImage.Create(0,0,[]);
LazImg.DataDescription := GetDescriptionFromDevice(LCLCanvas.Handle,
RotatedWidth,RotatedHeight);
// draw the rotated image to the LazImg ...
// create the widgetset bitmap
LazImg.CreateBitmaps(BitmapHnd, DummyHnd, True);
StretchBlt(LCLCanvas.Handle,x,y,LazImg.Width,LazImg.Height,
BitmapHnd, 0,0,LazImg.Width,LazImg.Height, LCLCanvas.CopyMode);
end;
Mattias
More information about the fpc-devel
mailing list