开发者

Known problem or am I overlooking something? IPicture gives wrong size @ 125% (but not normal or 150%)

开发者 https://www.devze.com 2023-03-24 20:38 出处:网络
I think I know what\'s going on.See the second edit at the end of this message. In a Win32 app in C/C++, I\'m working with (not the original author of) code that uses the IPicture class to draw a bit

I think I know what's going on. See the second edit at the end of this message.

In a Win32 app in C/C++, I'm working with (not the original author of) code that uses the IPicture class to draw a bitmap in a dialog box. It works at normal size, and when the user scales "text magnification" to 150%, the graphics scale automagically as well, but not at 125%.

As a reminder, Windows lets you go to Ease of Access (in Windows 7) and "Change the size of text and icons" to either Normal (100%), Medium (125%), or Larger (150%).

IPicture loads the graphic (pixel width size 775) with a HIMETRIC (similar to TWIP) value of 20505 when run at 100%, and when run at 150%, and at those scales it draws properly onscreen (the second is enlarged, but proportionally correct), but at 125% it has a normal size (in a larger dialog) at a HIMETRIC width of 16404 (smaller than the other two, which scale correctly).

So it seems that for some reason the width and height are giving out-of-scale values for 125%, although they work properly at 100% (smaller) and 150% (higher). Any ideas?

On edit:

LONG gwWidth, gwHeight; // HIMETRIC units
m_spIPicture->get_Width(&gwWidth);
m_spIPicture->get_Height(&gwHeight);
{
     char msg[80];
     sprintf(&msg[0], "Preparing width %d height %d HIMETRICs\n", gwWidth, gwHeight);
     OutputDebugString(msg);
}

where

IPicture* m_开发者_如何学PythonspIPicture;

All graphics act like this, it's not just the one I was asking about. Each reports the correct size in 125% and identical values for 100% and 150%.

I'm tempted to just do this stuff by hand (at least, get the DPI myself and calculate the values).

On edit: The confusion is why I'm getting identical values for 100% and 150%, but 125% is scaled differently. With any numbering system change, I'd expect (generically) one of three outcomes - no change, change progressively higher, change progressively lower.

In reading more about DPI virtualization, this page at http://msdn.microsoft.com/en-us/library/dd464659.aspx explains the mystery with the comment "When the DPI is set to 144, the operating system automatically enables DPI virtualization.". (Note that 144 is 150% mode).

I'm still learning this app (I inherited it from elsewhere), but apparently it's not DPI aware, meaning that it will virtualize, which is fine in this case (almost), but the virtualization doesn't kick in until 150%, meaning we're kinda screwed at 125%. So, I either need to make it virtual at 125%, or aware at 125% and 150%, but at least now I know why it's acting differently.


Converting your HIMETRIC value of 20505 gives 8.073 inches; dividing into the number of pixels (775) gives 96 DPI. This is the standard Windows configuration, so far so good.

Converting your HIMETRIC value of 16404 gives 6.458 inches; dividing into the number of pixels gives 120 DPI. This is exactly 96*125%, so it too seems OK.

The 150% setting should give 144 DPI; the HIMETRIC value should then be 13670. Are you sure get_Width is returning the same value here that it did for Normal mode?

Seeing some sample code where you call Render would help immensely.


I'm not at the office this very second, so I can't easily dig up the code, but yes, I expect a third number. I either expected all numbers to be identical, or all numbers to be different, and the one possible reason for them being like they are didn't seem plausible (I won't bore you with that explanation). At any, it doesn't work. I have run it multiple times checking the different values, wishing I was wrong, but I keep getting those numbers.

I'll look at again, and post code if I don't see anything acting different on the zillionth+1 time of looking at it.

Thanks

  • Tab
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号