Reputation: 781
I'm using Delphi XE8.
I'm loading a background image to my Image:
var
Png: TPngImage;
begin
Png := TPngImage.Create;
try
Png.LoadFromResourceName(HInstance, 'background');
Image1.Picture.Graphic := Png;
finally
Png.Free;
end;
This works alright, but when I try to draw on the image's canvas (I tried LineTo
) I get this error:
Can only modify an image if it contains a bitmap
How can I draw on an image which I have loaded a picture into?
Upvotes: 3
Views: 1613
Reputation: 612954
The answer can be found in the error message that you quoted:
Can only modify an image if it contains a bitmap.
So, create a bitmap object, assign the PNG image to that bitmap, and then assign that bitmap to the TImage
control's Picture
.
Upvotes: 4