From: Eli Zaretskii <eliz@gnu.org>
To: Daniel Colascione <dancol@dancol.org>
Cc: lekktu@gmail.com, 10397@debbugs.gnu.org
Subject: bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround
Date: Fri, 30 Dec 2011 10:51:40 +0200 [thread overview]
Message-ID: <8362gyv3vn.fsf@gnu.org> (raw)
In-Reply-To: <4EFD2D75.3030603@dancol.org>
> Date: Thu, 29 Dec 2011 19:18:13 -0800
> From: Daniel Colascione <dancol@dancol.org>
> Cc: 10397@debbugs.gnu.org
>
> > Hmm. Shouldn't in fact GetDeviceCaps (hdc, NUMCOLORS) always be <= 256?
> >
> > According to http://msdn.microsoft.com/en-us/library/dd144877(v=vs.85).aspx
> >
> > NUMCOLORS
> > Number of entries in the device's color table, if the device has a
> > color depth of no more than 8 bits per pixel. For devices with greater
> > color depths, 1 is returned.
> >
> > (It says "1", but it's a typo for "-1".)
>
> Good catch. What about this (untested) code?
>
> hdc = GetDC (dpyinfo->root_window);
> if (dpyinfo->has_palette)
> cap = GetDeviceCaps (hdc, SIZEPALETTE);
> else if (dpyinfo->n_cbits <= 8)
> /* According to the MSDN, GetDeviceCaps (NUMCOLORS) is valid only
> for devices with at most eight bits per pixel. It's supposed
> to return -1 for other displays, but because it actually
> returns other, incorrect values under some conditions (e.g.,
> remote desktop), only use it when we know it's valid. */
> cap = GetDeviceCaps (hdc, NUMCOLORS);
> else
> cap = -1;
There's a comment near the end of the GetDeviceCaps documentation
saying this:
NUMCOLORS doesn't always return one with more than 256 colors
The documentation for NUMCOLORS is wrong, devices that support more
than 256 colors often return -1 and some virtual machines can return
the number of Windows reserved colors (i.e. 20), even in high color
mode. Combine the NUMCOLORS return value with BITSPIXEL and PLANES
to reliably detect indexed color.
So how about using `1 << (n_planes * n_cbits)' (which we compute when
NUMCOLORS call returns -1) unconditionally? IOW, why do we need to
call GetDeviceCaps(..., NUMCOLORS) here in the first place?
next prev parent reply other threads:[~2011-12-30 8:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-29 14:05 bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround Daniel Colascione
2011-12-29 16:13 ` Juanma Barranquero
2011-12-29 16:23 ` Daniel Colascione
2011-12-29 16:27 ` Juanma Barranquero
2011-12-29 16:42 ` Daniel Colascione
2011-12-29 16:45 ` Juanma Barranquero
2011-12-29 22:59 ` Daniel Colascione
2011-12-29 23:10 ` Juanma Barranquero
2011-12-29 23:13 ` Daniel Colascione
2011-12-29 23:18 ` Juanma Barranquero
2011-12-30 3:07 ` Juanma Barranquero
2011-12-30 3:18 ` Daniel Colascione
2011-12-30 8:51 ` Eli Zaretskii [this message]
2011-12-30 9:00 ` Eli Zaretskii
2011-12-30 12:24 ` Juanma Barranquero
2012-08-07 17:13 ` Eli Zaretskii
2012-08-07 17:33 ` Daniel Colascione
2012-08-07 18:07 ` Eli Zaretskii
2016-02-25 6:25 ` Lars Ingebrigtsen
2016-12-13 0:04 ` Glenn Morris
2011-12-30 1:04 ` Jason Rumney
2011-12-30 1:10 ` Daniel Colascione
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8362gyv3vn.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=10397@debbugs.gnu.org \
--cc=dancol@dancol.org \
--cc=lekktu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.