I have a Bitmap variable and I copy smaller 32×32 png files (loaded as Bitmaps) onto the bitmap. However, some png’s are scaled up (always the same ones) and appear as 36×36 for example after copying. Almost as if some png’s have another DPI or something? How can I prevent this?
Graphics g = Graphics.FromImage(destinationImage);
g.DrawImage(sourceImage, location); // sourceImage is sometimes larger than it actually is. On disk it is 32x32 but after copying it might be bigger...
g.Dispose();
I guess you are right about DPI, as it’s stated in the documentation:
I’m too lazy to make a test project, but I think Graphics.DrawImage(Image, Rectangle) with rectangle size equals to source image size will fix your problem.