Results 1 to 3 of 3

Thread: Problem with stretched images in largeicon view

  1. #1

    Thread Starter
    Addicted Member JRSofty's Avatar
    Join Date
    Jan 2004
    Location
    Somewhere in Germany
    Posts
    149

    Problem with stretched images in largeicon view

    Hi everyone,

    I've got some issues with a Listview control set to LargeIconView with an ImageList control assigned to the LargeIconImageList property of the Listview.

    I've got the Imagelist control's image size set to 110,110.

    The thumbnails which are stored in a database have a MAXIMUM size of 110 x 110. Meaning some thumbnails may be 110 x <110 and some may be <110 x 110 (either the Height or the Width will be 110, seldom will both be 110).

    Loading the images into the Imagelist is working just fine. Showing the images in the Listview seems to work except that the images are stretched because they are forced back to 110 X 110.

    Is there a work around for this, or will I need to paste the thumbnail onto a 110 X 110 blank Background image first before adding to the imagelist control?

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Problem with stretched images in largeicon view

    The ImageList will always resize images to the size set for the imagelist, and AFAIK there is no workaround for that so I guess you just need to load them into 110x110 image first as you suggested yourself.

  3. #3

    Thread Starter
    Addicted Member JRSofty's Avatar
    Join Date
    Jan 2004
    Location
    Somewhere in Germany
    Posts
    149

    Re: Problem with stretched images in largeicon view

    Thanks for the confirmation. I figured that was what the problem was.

    I've tested out the other way of doing it and it is sooooooo sloooooooow.

    I'm not sure why it takes so long to make a new thumbnail with a border around it.

    My code to do this looks like this:
    Code:
    Public Function prepImg4List(ByVal b As Bitmap) As Bitmap
            Dim tn As Bitmap = New Bitmap(My.Settings.thumbnailSize, My.Settings.thumbnailSize, PixelFormat.Format32bppRgb)
            Dim g As Graphics = Graphics.FromImage(tn), leftAdjust As Integer, topAdjust As Integer
            g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
            g.DrawRectangle(Pens.White, New Rectangle(0, 0, My.Settings.thumbnailSize, My.Settings.thumbnailSize))
            leftAdjust = CInt((tn.Width - b.Width) / 2)
            topAdjust = CInt((tn.Height - b.Height) / 2)
            g.DrawImage(b, New Rectangle(leftAdjust, topAdjust, b.Width, b.Height), 0, 0, b.Width, b.Height, GraphicsUnit.Pixel)
            g.Dispose()
            g = Nothing
            Return CType(tn, Image)
    End Function
    I'm pretty sure I'm going to need to fill the rectangle as well seeing that I'm getting a black box behind the image instead of the white one I'm expecting. The problem I'm having right now is that this takes so long to build. Does anyone have a faster way of doing this or perhaps to clean up my code to make it faster?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width