I have a ListView
with View
property set to LargeIcon
. And I have an ImageList
as image source for ListView
.
What I want is to display both vertically and horizontally oriented images in ListView
but ImageList
have only a single property ImageSize
for all images in its collection so for example if I set that property to 150x100 and add a vertical image (100x150) to collection - ListView
automatically stretches it to 150x100.
So as I understand I need some ImageList
, in which every image is stored with its original size. Any thoughts about how to do that?
Thanks in advance.
To keep from stretching you can use cross-multiplication.
or
In code it looks something like this
or
and
or
Then when creating your new bitmap you can draw a scaled image on the new bitmap using the desired size and the derived size.
I have had this problem myself, Here is what I did, I hope it will help you as well, first determine the biggest image size you would use ( for example 200x200) then use Png or Gif images (all 200x200) with transparent backgrounds.
have a look at these two images i have created as an example.
but I make it like this to avoid stretching: