I have this test source code that is supposed to load a JPG image, draw a rectangle on top of the image, then save the output. When I run it, it loads the JPG properly, correctly draws the rectangle onscreen, and saves the JPG properly, but the rectangle does not appear in the saved image as it appeared on the screen.
I have a different version of this code where the rectangle actually vanishes from the on-screen image when the SaveToFile line is executed! I really don't understand what is going on. If I try drawing the rectangle to Image1.picture.bitmap.canvas instead of Image1.canvas, it doesn't draw the rectangle correctly and I just get a gray, opaque area where the rectangle should be.
I'm probably being an idiot but I need some pointers on what I am missing here. I tried searching the Internet for help but I can't find anything except significantly more complicated examples.
s1 := 'c:\something\source.jpg';
Image1.Picture.LoadFromFile(s1);
with Image1.Canvas do // Draw rectangle overlay
begin
brush.style := bsSolid;
brush.color := $0000AA;
Rectangle(200,200,300,300);
end;
Image1.Picture.SaveToFile('c:\something\destination.jpg');