load image and display in a canvas as a thumb

  1. 7 months ago

    David C

    20 Apr 2017 Boston, MA
    Edited 7 months ago

    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://docs.xojo.com/index.php/Graphics.DrawPicture .

  2. Beatrix W

    20 Apr 2017 Pre-Release Testers Answer Europe (Germany)

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

  3. Emile S

    21 Apr 2017 Europe (France, Strasbourg)

    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.

  4. David C

    21 Apr 2017 Boston, MA

    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 ..

  5. Beatrix W

    21 Apr 2017 Pre-Release Testers Europe (Germany)

    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.

  6. David C

    21 Apr 2017 Boston, MA

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

    Thank you for your help.

or Sign Up to reply!