[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workar
From: |
Eli Zaretskii |
Subject: |
bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround |
Date: |
Fri, 30 Dec 2011 10:51:40 +0200 |
> 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?
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, (continued)
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Daniel Colascione, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Juanma Barranquero, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Daniel Colascione, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Juanma Barranquero, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Daniel Colascione, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Juanma Barranquero, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Daniel Colascione, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Juanma Barranquero, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Juanma Barranquero, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Daniel Colascione, 2011/12/29
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround,
Eli Zaretskii <=
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Eli Zaretskii, 2011/12/30
- bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Juanma Barranquero, 2011/12/30
bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround, Jason Rumney, 2011/12/29