How to discover screen depth

josh at cadnetix.com josh at cadnetix.com
Fri Dec 2 03:22:30 AEST 1988


Here is a code fragment that determines the depth of a screen:

#include        <suntool/sunview.h>

	...
	Pixrect *screen;
	...
	/* open frame buffer */
	if ((screen = pr_open("/dev/fb")) == 0)
		error("Can't open screen!\n");

	if (screen->pr_depth == 1) {
		/* Black and white screen */
	}
	else if (screen->pr_depth == 8) {
		/* 8 Bit (gray scale or color) */
	}
	else {
		error("Weird monitor depth: %d\n", screen->pr_depth);
	}
	...

    Joshua Goldstein	UUCP: cadnetix!josh
    Cadnetix Corp.	      {uunet,boulder,sunpeaks}!cadnetix!josh
    5775 Flatiron Pkwy
    Boulder, CO 80301



More information about the Comp.sys.sun mailing list