DrawPicture does not show in Windows but ok in Mac

I am drawing a picture in a canvas using the following code in the Paint event of the canvas. The picture is drawn in the Mac application, but it is not drawn in a Windows application. Where am I going wrong ?

if default_picture_front <> Nil then
Dim w,h As Double
w = 216
h = (w/default_picture_front.Width)*default_picture_front.Height
if h > default_canvas_front.Height then
h = 144
w = (h/default_picture_front.Height)*default_picture_front.Width
end
g.DrawPicture(default_picture_front,0,0,w,h,0,0,default_picture_front.Width,default_picture_front.Height)
end

Check if the picture is Nil on Windows. I see your code has guard against it but nothing to tell you if it was nil.

Or is the canvas being refreshed properly in Windows. Make certain the paint event is firing for your canvas.

I select the default_picture_front file from the action event of a button with the following code

default_file_front = GetOpenFolderItem(FileTypes1.Jpeg)
if default_file_front = Nil then
if confirm(“Remove Front Default File ?”) then
default_picture_front = Nil
default_canvas_front.Invalidate
save_button.Enabled = True
end
Return
end
Dim w,h,lm,bm As Double
default_picture_front = default_file_front.OpenAsVectorPicture
w = 216
h = (w/default_picture_front.Width)*default_picture_front.Height
if h > default_canvas_front.Height then
h = 144
w = (h/default_picture_front.Height)*default_picture_front.Width
end
default_canvas_front.Width = w
default_canvas_front.Height = h
default_canvas_front.EraseBackground = True
default_canvas_front.Invalidate

I’m pretty sure OpenAsVectorPicture relies on the operating system so it could be that the format you are trying to open has no supported within MS-Windows.

1 Like

You shouldn’t be using OpenAsVectorPicture with JPEGs anyway.

1 Like

Yes. I used Picture.Open and it worked fine.
Thanks