🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #1660

Re: RGB() Problems?

#1660
From: John Munsch
Date: Thu, 14 Mar 1991 23:30
20 lines
1512 bytes
In article <DKEMPER.91Mar13150624@hqsun2.oracle.com> dkemper@oracle.com (David J. Kemper) writes:
>The problem arises when I want to read pixels from the display. I
>create a screen device context (CreateDC("DISPLAY", NULL, NULL, NULL)
>and try to read from it using GetPixel(). Well, the DWORD colorref I
>get back ALWAYS has the high byte of 0, meaning it's a direct RGB (?).
>The problem is that this direct color is WRONG. It's a match when the
>color happens to be a standard Windows color (as in window title bars,
>menu backgrounds, etc), but is "garbage" when it is one of my enhanced
>color palette entries.

Hmm...  I've never tried doing that sort of thing with a CreateDC.

I assume you have the handle to the window you're doing all this in available.
If so, try doing a GetDC() on the window handle and performing the GetPixels
on that DC handle instead.

P.S.  If you are grabbing large sections of the screen via GetPixel() you may
find it more economical (timewise) to use something like GetDIBits() instead.

John Munsch
Technical Details
Message-ID: <28293@spudge.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!evax!utacfd!letni!rwsys!spudge!johnm
References: <DKEMPER.91Mar13150624@hqsun2.oracle.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!evax!utacfd!letni!rwsys!spudge!johnm
From: johnm@spudge.UUCP (John Munsch)
Newsgroups: comp.windows.ms.programmer
Subject: Re: RGB() Problems?
Message-ID: <28293@spudge.UUCP>
Date: 14 Mar 91 23:30:26 GMT
References: <DKEMPER.91Mar13150624@hqsun2.oracle.com>
Reply-To: johnm@spudge.UUCP (John Munsch)
Distribution: comp.windows.ms.programmer
Organization: Friends of Guru Bob
Lines: 20