Windows 10-64 Xojo2017r3
Objective to load picture located at C:\picsFolder\1_1 into Canvas1.
I don’t want the 'user to do anything except press a button
and automatically see the picture. No dialogue’s etc. just code.
- create a global PICTURE var myPicture
- load picture from HD (see PICTURE.OPEN in LangRef)
- in Canvas Paint Event … g.DrawPicture myPicture,0,0
Whats wrong with the example here:
http://documentation.xojo.com/index.php/Picture.Open
Modified a bit:
[code] Dim picFile As FolderItem
picFile = GetFolderItem("")
If picFile <> Nil Then
Dim pic As Picture
pic = Picture.Open(picFile)
Canvas1.Backdrop = pic
End If[/code]
What about something like this in the action event of the pushbutton (that add an exists check):
dim f as new folderitem("C:\\picsFolder", FolderItem.PathTypeNative)
if f <> nil and f.exists then
f = f.child("1_1")
if f <> nil and f.exists then
dim p as picture = picture.open(f)
if p <> nil then
canvas1.Backdrop = p
end if
end if
end if
Never leave the PC to choose the image size
but always paint the background in Paint
g.drawpicture picture, 0,0, canvas.width, canvas.height, 0,0, Picture.width, Picture.height
[quote=389369:@Rudolf Jackel]Never leave the PC to choose the image size
but always paint the background in Paint
g.drawpicture picture, 0,0, canvas.width, canvas.height, 0,0, Picture.width, Picture.height[/quote]
depends on what you want… if you want a ScaleToFill then sure… otherwise, not so much