<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px">
<DIV>Well, I hope to soon share your optimism for "easy". </DIV>
<DIV> </DIV>
<DIV>Since these numbers wind up being default values for the xres/yres and since changing the defaults has made a big difference in the results, it would seem that most code must not be computing these, but relying on the default values to be correct. </DIV>
<DIV> </DIV>
<DIV>Since these numbers may be different for every program run on a different monitor (potentially), the question becomes how to effect a change that will work in all cases without having to recompile vbtkit.</DIV>
<DIV> </DIV>
<DIV>Does this mean we have to track down each use of Image.Raw and put in code to compute the dpi? Or is there some way we can do this during an initialization sequence? but alas, how to deal with the defaults supplied in the declaration?</DIV>
<DIV> </DIV>
<DIV>Regards,</DIV>
<DIV>Randy<BR><BR>>>> Jay <jayk123@hotmail.com> 8/7/2008 8:16 PM >>><BR><BR>Awesome. I expect it is easy from here. Thanks David!<BR><BR>I *assume* the 75 should have been 86 in the one case,<BR>but close enough that nobody noticed.<BR>So these numbers come pretty directly from the GetDeviceCaps / GetSystemMetrics.<BR><BR>And then X Windows too.<BR>Does anyone have a high DPI monitor running X Windows?<BR>Probably easy enough to do this blind.<BR><BR>I'm trying to ignore the fact that systems have multiple<BR>monitors, with varying dpi. You are supposed to loop your<BR>drawing over monitors and compute what it looks like per-monitor.<BR>I'm just making that up, right? :)<BR><BR>- Jay<BR><BR>________________________________<BR><BR>Date: Thu, 7 Aug 2008 19:42:33 -0400<BR>From: rcoleburn@scires.com<BR>To: m3devel@elegosoft.com; jayk123@hotmail.com; dabenavidesd@yahoo.es<BR>Subject: Re: [M3devel] pixmap problem (some success)<BR><BR><BR><BR>Ok, I solved the Microsoft problem.<BR><BR><BR><BR>Here are the results on Dell M4300 at 1920x1200:<BR><BR><BR><BR>horizonal pixels 1920<BR>veritical pixels SM_CYSCREEN 1200<BR>horizontal millimeters 330<BR>veritical millimeters 206<BR>horizontal pixels per millimeter 5.818182<BR>vertical pixels per millimeter 5.825243<BR>horizontal pixels per inch 147.781818<BR>vertical pixels per inch 147.961165<BR><BR>Wow! these numbers are radically different than the IBM T60 at 1280x1024:<BR><BR><BR><BR>horizonal pixels 1280<BR>veritical pixels SM_CYSCREEN 1024<BR>horizontal millimeters 375<BR>veritical millimeters 300<BR>horizontal pixels per millimeter 3.413333<BR>vertical pixels per millimeter 3.413333<BR>horizontal pixels per inch 86.698667<BR>vertical pixels per inch 86.698667<BR><BR>Now, if you look at the Windows dpi setting for the 1920x1200 machine, it says 96dpi, but this is in the General tab of the Display properties Advanced settings. I suspect this is just the dpi setting applied to fonts.<BR><BR><BR><BR>I tried plugging the numbers into Image.i3 as suggested by Daniel:<BR><BR>TYPE<BR> Raw = OBJECT<BR> width, height: INTEGER;<BR> xres: REAL := 147.781818; (* in pixels per inch *)<BR> yres: REAL := 147.961165; (* in pixels per inch *)<BR> METHODS<BR> get (h, v: INTEGER): Pixel;<BR> set (h, v: INTEGER; pixel: Pixel);<BR> END;<BR><BR>When I do this, my pixmaps look correct on the 1920x1200 display!!!!!<BR><BR><BR><BR>Now, the problem I am faced with is how to come up with a way that the code will work on any type of monitor. I can't edit Image.i3 for every resolution and produce a different binary. Any ideas?<BR><BR><BR><BR>Regards,<BR><BR>Randy<BR><BR><BR>>>> Jay 8/5/2008 9:01 AM>>><BR><BR><BR>Randy, I'm pretty clueless here.<BR>I don't do gui or graphics.<BR>If anyone has a clue, please stand up.<BR>If you can get us code to run, please do.<BR>But I think I need multiple particularly configured machines too.<BR><BR>I'm curious what this code prints on the systems:<BR><BR>#include<BR>#include<BR><BR>int main()<BR>{<BR>int pix_ver = { 0 };<BR>int pix_hor = { 0 };<BR>int mm_hor = { 0 };<BR>int mm_ver = { 0 };<BR>HWND hwnd = { 0 };<BR>HDC hdc = { 0 };<BR><BR>hwnd = GetDesktopWindow();<BR>hdc = GetDC(hwnd);<BR>mm_hor = GetDeviceCaps(hdc, HORZSIZE);<BR>mm_ver = GetDeviceCaps(hdc, VERTSIZE);<BR>pix_hor = GetSystemMetrics(SM_CXSCREEN);<BR>pix_ver = GetSystemMetrics(SM_CYSCREEN);<BR><BR>printf("horizonal pixels %d\n", pix_hor);<BR>printf("veritical pixels SM_CYSCREEN %d\n", pix_ver);<BR>printf("horizontal millimeters %d\n", mm_hor);<BR>printf("veritical millimeters %d\n", mm_ver);<BR><BR>printf("horizontal pixels per millimeter %f\n", (((float) pix_hor) / ((float) mm_hor)));<BR>printf("vertical pixels per millimeter %f\n", (((float) pix_ver) / ((float) mm_ver)));<BR><BR>printf("horizontal pixels per inch %f\n", (((float) pix_hor) / ((float) mm_hor) * 10.0 * 2.54));<BR>printf("vertical pixels per inch %f\n", (((float) pix_ver) / ((float) mm_ver) * 10.0 * 2.54));<BR><BR>return 0;<BR>}<BR><BR><BR>for me:<BR><BR>$ gcc dpi.c -luser32 -lgdi32<BR><BR>jay@jay-win9 /dev2/j/dpi<BR>$ ./a<BR>horizonal pixels 1280<BR>veritical pixels SM_CYSCREEN 800<BR>horizontal millimeters 384<BR>veritical millimeters 240<BR>horizontal pixels per millimeter 3.333333<BR>vertical pixels per millimeter 3.333333<BR>horizontal pixels per inch 84.666667<BR>vertical pixels per inch 84.666667<BR><BR>(Visual C++ is fine:<BR>cl dpi.c user32.lib gdi32.lib<BR>.\dpi<BR>)<BR><BR>I wonder if lying in this code:<BR><BR>Searching for 'GetDeviceCaps'...<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(25): VAR res := NEW(T); n_colors := GetDeviceCaps (WinGDI.NUMCOLORS);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(32): res.depth := GetDeviceCaps(WinGDI.BITSPIXEL); (* John Karnak 8/3/98 *)<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(68): mm_hor = GetDeviceCaps (WinGDI.HORZSIZE),<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(69): mm_ver = GetDeviceCaps (WinGDI.VERTSIZE) DO<BR><BR>Searching for 'res.res[Axis.T.'...<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(71): res.res[Axis.T.Hor] := FLOAT(pix_hor) / FLOAT(mm_hor);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(72): res.res[Axis.T.Ver] := FLOAT(pix_ver) / FLOAT(mm_ver);<BR><BR><BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(89):PROCEDURE GetDeviceCaps (cap: Ctypes.int): INTEGER =<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(93): res := WinGDI.GetDeviceCaps (hdc, cap);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(98): END GetDeviceCaps;<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScrnColorMap.m3(268): cnt := WinGDI.GetDeviceCaps (hdc, WinGDI.NUMCOLORS);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScrnFont.m3(316): LogicalPixelsPerVertInch := WinGDI.GetDeviceCaps(er.hdc, WinGDI.LOGPIXELSY);<BR>9 occurrence(s) have been found.<BR><BR><BR>Searching for '1000.0'...<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScrnPixmap.m3(463): bmih.biXPelsPerMeter := ROUND (st.res[Axis.T.Hor] * 1000.0);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScrnPixmap.m3(464): bmih.biYPelsPerMeter := ROUND (st.res[Axis.T.Ver] * 1000.0);<BR><BR><BR>and just claiming 96dpi is the way to go.<BR>Can you try that??<BR><BR><BR>Specifically try setting res.res[Axis.T.Hor] and .Ver to 3.779527559055118.<BR>Or heck to 3.3333 like my laptop has.<BR><BR><BR>Or maybe claiming ignorance and setting biXPelsPerMeter and biYPelsPerMeter to 0???<BR>Claiming ignorance feels better than lying of course. :)<BR><BR>Hm, so throw in also:<BR><BR>printf("LogicalPixelsX %u\n", GetDeviceCaps(hdc, LOGPIXELSX));<BR>printf("LogicalPixelsY %u\n", GetDeviceCaps(hdc, LOGPIXELSY));<BR><BR>I get the magic number 96.<BR><BR>- Jay<BR><BR></DIV></BODY></HTML>