Ok, I can read the images from a string type path and load them in a Canvas window. There are images of various formats, how do you make them have the resolution of the canvas window when they are loaded?
Var f As FolderItem
Var p As Picture
f = New FolderItem(PathImmagine)
p = Picture.Open(f)
Canvas1.Backdrop = p
I have tried looking at the guide and examples, but I don’t understand anything about it. In VB6 it was enough to select the Autoredraw property that does not exist here, I would like to understand how to do it. Thanks in advance for the help.
Here is your code adapted to use the Function below:
Var f As FolderItem
f = New FolderItem(PicturePath, FolderItem.PathModes.Native)
Var p1 As Picture
p1 = Picture.Open(f)
Var p2 As Picture = ProportionalScale(p1,Canvas1.Width,Canvas1.Height)
Canvas1.Backdrop = p2
Function adapted from the thread:
Public Function ProportionalScale(Pic as Picture, Width as integer, Height as Integer) As Picture
// calculate the scale factor
dim factor as Double = min( Height / Pic.Height, Width / Pic.Width )
// Calculate new size
dim w as integer = Pic.Width * factor
dim h as integer = Pic.Height * factor
// create new picture
dim NewPic as new Picture( w, h, 32 )
// draw picture in the new size
NewPic.Graphics.DrawPicture( Pic, 0, 0, w, h, 0, 0, Pic.Width, Pic.Height )
// return scaled image
Return NewPic
End Function
The CANVAS is in a portion of the window … exactly in the upper left part. And what should I include in the PAINT event? Maybe it can be useful for something else.