load image and display in a canvas as a thumb

I would like to load an exisiting image , without altering this image i would like to scale it down to be displayed in a small Canvas approx 100 x 100 or so, a thumbnail …

this code loads the image and displays it’s full size with no scaling.

Please Advise.

dim f as FolderItem
dim p as Picture
f = SpecialFolder.Documents.Child("PHOTOS").Child("doc.jpg")
p = f.OpenAsPicture

Canvas1.Backdrop = p 
Canvas1.backdrop.HorizontalResolution = 100
Canvas1.backdrop.VerticalResolution = 100

Use the paint event to draw your picture. Have a look at the canvas documentation: http://documentation.xojo.com/index.php/Graphics.DrawPicture .

Also, Resolution <> Width / Height even if at first it seems to be the same.

Also: excepted if your photos are “squared”, you will have to center them (in both Width and Height, but not at the same time). You will achieve that with DrawPicture too. Read the documentation.

At last, if you think (or not) you will have to use the shrink/enlarge mathod elsewhere in the code, put it directly in a Method and call it from your above code.

Ask if this is unclear.

I have a listBox of images. i only want the photo to be scaled / loaded only when one of the images in the lstbox is clicked.
it is firing on the pain event …

Most events cause pain. You have to show us a bit more of your code.

The click of the listbox should call refresh on the canvas. Then you have to tell the canvas which image to use.

ok i think i got it …
any problems i’ll let you know.

Thank you for your help.