Thumbnail view ?

Consider a app.

User clicks add button and selects multiple images. Now I want the program to show the selected files in thumbnail view. Now how to achieve this objective

Can I use listview as container to hold thumbnails

Thanks



Answer this question

Thumbnail view ?

  • Tibor den Ouden

    I did this before by using:

    ' a system.drawing.bitmap can create a thumbnail
    ' get the file image
    Dim bm As System.Drawing.Bitmap = DirectCast(Bitmap.FromFile(path), Bitmap)

    'turn bm into a thumbnail
    bm = DirectCast(bm.GetThumbnailImage(desiredWidth, desiredHeight, Nothing, IntPtr.Zero), Bitmap)
    bm.SetResolution(96, 96) ' set to desktop resolution

    Return bm


    SetResolution is called as GetThumbnailImage does strange things...
    If I start with this image
    Height, Width: 2960, 3928
    HRes, VRes: 600, 600

    And ask for a 120x120 pixel thumbnail, it returns:
    Height, Width: 120,120
    Hres, VRes: 1173.11609, 1556.75671

    dots/inches = 1173, so inches = 120/1173

    When displayed on screen: dpi = 96 (monitor resolution)
    so dots/inches = 96 => dots = 96*inches = 96*120/1173 = 9.8 Pixels Wide (Argh!)

    So we use SetResolution to 96dpi to fix it...

    You can add images to a listview, listbox, or dataGridView.

    For a listview:

    Add the images to an imageList and set the key to the filename when you do so (see the overload list of ImageList.Images.Add in the msdn help)

    Set the listview.LargeImageList to the imageList

    Then add Files to the ListView, and specify the filename as the ImageList key. (see the overload list of ListView.Items.Add)



  • Elkoda

    hi.

    Is your problem solved

    Thank you,
    Bhanu.



  • Thumbnail view ?