Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I detect a Grayscale Monitor 2

Status
Not open for further replies.

Zyrenthian

Programmer
Mar 30, 2001
1,440
US
Hi All,
Just a quick question. I have an app that highlights the current selection in red but on a black and white monitor, this is not always readilly noticable. What I have been trying to find out is is there a way to detect if the user has a grayscale monitor?

Just a quick FYI... DM_GRAYSCALE is not obsolete so I cant use that.

Thanx,
Matt
 
Try getDeviceCaps (either API or MFC's cdc::getDeviceCaps). Check MSDN for it, you should be able to find the information you want (I think... I hope it gives you a clue about grayscales).

There is also another function, GetMonitorInfo, but I never used it...

HTH [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Tried... but I cant be 100 percent on what I get back... I have tried bits per pixel and a few others. I also looked into GetDisplaySettings

Mainly, everything I get back is printer related and not monitor related. It would have been nice if DM_GRAYSCALE was still available but there is not even a note saying what to use in its place. Just a lil' ol' comment saying

// obsolete

The only thing I have found that MIGHT be good is something to do with GammaRamp

The funciton is something like:
GetDisplayGammaRamp or
GetDeviceGammaRamp

Cant remember exactly and I dont have the code in front of me at the moment. WHat I did find out though is that the API call returns true on color and false on gray... THe only tough part is that we only have one grayscale monitor at work :-( so I am not completely sure if it is the right call.

Matt
 
Well, this would be an awkward solution, but
what about CreateCompatibleBitmap called on a window HDC (probably the program's main frame)?
You could querry then the bitmap information since the resulted bitmpa has the same color information as the device.

Never tried it, but it just might work... :))) [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Hi,

The following code will determing hi-colour video modes, it may be of use to you.
{
int dib_size;
LPBITMAPINFOHEADER dib_hdr;
HDC hdc;
HBITMAP hbm;
dib_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD);
dib_hdr = (LPBITMAPINFOHEADER) malloc(dib_size);
memset(dib_hdr, 0, dib_size);
dib_hdr->biSize = sizeof(BITMAPINFOHEADER);
hdc = GetDC(NULL);
hbm = CreateCompatibleBitmap( hdc, 1, 1 );
GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr,
DIB_RGB_COLORS);
GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr,
DIB_RGB_COLORS);
DeleteObject(hbm);
ReleaseDC(NULL, hdc);

printf("Current video mode is %lu-bit.\n", dib_hdr->biBitCount);

if (BI_BITFIELDS == dib_hdr->biCompression)
{
DWORD * fields = (DWORD*) ((char*)dib_hdr +
dib_hdr->biSize);
switch (fields[0])
{
case 0xf800:
printf(" (565 BGR pixel alignment)\n");
break;
case 0x7c00:
printf(" (555 BGR pixel alignment)\n");
break;
case 0xff0000:
printf(" (888 BGR pixel alignment)\n");
break;
case 0x0000ff:
printf(" (888 RGB pixel alignment)\n");
break;
default:
printf(" (Unknown pixel alignment %x:%x:%x)\n",
fields[0], fields[1], fields[2] );
}
}

free(dib_hdr);
}

HTH
William
Software Engineer
ICQ No. 56047340
 
Well, i am sorry to say it did not work :-( I am still open to any ideas you may have on how to determine this.

Matt
 
I don't know if you were the star voting guy, but in that case, I would like to give it back to you :-(... [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Yep it was me... dont worry bout it :) It was a great idea! The problem is that the monitor is never really pinged with the DC, it is the video card. If the video card can support color then it says im color. I have decided to make it a preferance in the app and just store it as a boolean value in the registry. Thanx for the help.

Matt
 
If you can get access to the video card (using interrupt 10H) you can determine the amount of memory, if the card has = 32Kb then the mode will be GreyScale.

Just a thought, but it maybe more bother that it's worth.

William
Software Engineer
ICQ No. 56047340
 
But what if you have a GForce or some ultra performant graphic card on a black&white monitor? That won't do either, I guess...

Speaking of registry... Couldn't there be a value THERE, specifying the monitor type? [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
That's a fair point you may well me on a hiding to nothing with this one. The other option I guess is to allow the user to change the colour of the hilight (if it proves unreadable).

Or inverse the corrections; black text on a white BG this in theory would work regardless of video mode.

Something else to consider!



William
Software Engineer
ICQ No. 56047340
 
I went with user preferences in the application itself. Nothing I tried seemed to work because the grayscale monitor I was testing against didnt care about TRUE Color or 256 color... it displayed fine in every way. When I hit the system to determine its settings, it was based on these.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top