I'm using WinForms to create a 512x512 px image with 96dpi resolution. After initialization, I use OnPaint
to draw this image using Graphics.DrawImage
. What I get as I run the program is the image shown below: essentially a 1024x1024 image which contains some jung vaguely resembling what I want to show, except it's made up of 2x2-pixel blocks all having uniformly identical colors. Which is weird.
Can someone help me figure out what is going on? This is only happening on high-DPI displays, the program works just fine on ordinary ones.
Update 1: I explicitly set the process to be DPI-unaware with SetProcessDpiAwareness(_Process_DPI_Awareness.Process_DPI_Unaware);
and explicitly call DrawImage
in a rectangle, i.e.,
e.Graphics.DrawImage(bmp,
new Rectangle(0, 0, 512, 512),
new Rectangle(0, 0, 512, 512), GraphicsUnit.Pixel);
and it did not help.
Edit 2: After turning DPI awareness on, I now get the same junk, but at the right size:
Edit 3: Finally got it, the artifacts were the results of my rendering things incorrectly on the CUDA side. The high-DPI nonsense was just a distraction.