octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties


From: Michael Goffioul
Subject: Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties
Date: Thu, 22 Jan 2009 18:57:43 +0000

I used the attached code instead (note the use LOGPIXELSX/Y and
ReleaseDC). The results are:

1280x800 pixels
320x200 mm
101.6 resx
101.6 resy
96 resx_log
96 resy_log
101.6 avg dpi
32 bit depth

Michael.


On Thu, Jan 22, 2009 at 3:08 PM, John W. Eaton <address@hidden> wrote:
> On 22-Jan-2009, Michael Goffioul wrote:
>
> | On Thu, Jan 22, 2009 at 2:13 PM, John W. Eaton <address@hidden> wrote:
> | > On 22-Jan-2009, Shai Ayal wrote:
> | >
> | > | OK. But I don't know how hard it will be to make this cross platform.
> | > | We might try to "steal" some code from fltk to discover the
> | > | platform.
> | >
> | > Why?  This seems to be a compile-time thing.  We can discover if the
> | > build system has X11, or is Windows, or is OS X, and then we just need
> | > to know how to get the screen characteristics on those systems.  I
> | > provided the example code for X11.  Now someone else needs to do the
> | > same for Windows and
OS X.
> |
> | Under Windows, it would be done using GetSystemMetrics and
> | GetDeviceCaps functions.
>
> Does the following program do the right thing?
>
> Thanks,
>
> jwe
>
>
> #include <iostream>
>
> #include <Windows.h>
>
> int
> main (void)
> {
>  HDC hdc = GetDC (0);
>
>  if (hdc)
>    {
>      int ht = GetDeviceCaps (hdc, VERTRES);
>      int wd = GetDeviceCaps (hdc, HORZRES);
>
>      std::cerr << wd << "x" << ht << " pixels" << std::endl;
>
>      double ht_mm = GetDeviceCaps (hdc, VERTSIZE);
>      double wd_mm = GetDeviceCaps (hdc, HORZSIZE);
>
>      std::cerr << wd_mm << "x" << ht_mm << " mm" << std::endl;
>
>      double resy = wd * 25.4 / wd_mm;
>      double resx = ht * 25.4 / ht_mm;
>
>      std::cerr << resx << " resx" << std::endl;
>      std::cerr << resy << " resx" << std::endl;
>
>      std::cerr << (resx + resy) / 2 << " avg dpi" << std::endl;
>
>      int depth = GetDeviceCaps (hdc, BITSPIXEL)
>
>      std::cerr << depth << " bit depth" << std::endl;
>    }
>  else
>    std::cerr << "failed to get device context" << std::endl;
>
>  return 0;
> }
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]