I am trying to calculate the size of a Rectangle
using the Height
and Width
of an image in my project. The image (icon) is 20px W and 16px H. When I load it in from a ImageList
and look at the image size, it shows that it is 16px X 16px.
I assume that there is some compression that is being applied to the image, but I am not very experienced in this area. I just need to get the correct, dimensions. Is there any way?
NOTE: I am not loading the file from disk... it is in my project.
This, simply, is what I am doing:
var tabPage = _tabControl.TabPages[e.Index];
var image = _tabControlImageList.Images[tabPage.ImageIndex];
var imageHW = Math.Max(image.Height, image.Width);
You can and must declare a ImageSize
you want to have, before you load the Images
into the ImageList
:
_tabControlImageList.ImageSize = new System.Drawing.Size(20, 16);
Afterwards all your Images
inside the ImageList
will have following size: 20x16px
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.