[comp.sys.mac.programmer] What's the screen depth?

rcook@eagle.wesleyan.edu (03/29/91)

Here's the deal:  I have an old style window (ie not color, a standard
grafport) and I do some color drawing in it with standard QuickDraw colors
(by setting ForeColor and BackColor)  This works fine on a machine in 16 color
mode or higher, but everything comes out black on a 2 or 4 color machine.  This
is expected since standard QuickDraw isn't picky about how colors interact.

Here's the problem:  I know how to sense if a machine has Color QuickDraw, but
how do you detect the bit depth/color mode?  I don't want to move to color
windows, because I want to keep only one set of drawing routines, thus not
keeping parallel sets for standard and color quickdraw.

Here's the disclaimer:  I read through IM-V last night and the only place it
seemed I could determine bit-depth was in a pixmap record.  I checked the
portbits field of my standard window (on a 256 color IIsi) and it was a true
bitmap and not a pixmap, so I guess I can't figure things out that way.  Tech
note #276 (I think, which I don't have...) mentions a SetDepth routine.  Is
there an analogous GetDepth routine?  If so, I couldn't find it in the tech
note index.

Please help me out on this one.  At least I'm not asking about the sound
manager (yet... :-)  Thanks.

-- 
------------------------
Randall Cook
rcook@eagle.wesleyan.edu
------------------------

hairston@henry.ECE.CMU.EDU (David Hairston) (03/29/91)

[rcook@eagle.wesleyan.edu writes:]
[] Here's the problem:  I know how to sense if a machine has Color QuickDraw,
[] but how do you detect the bit depth/color mode?  I don't want to move to
[] color windows, because I want to keep only one set of drawing routines,
[] thus not keeping parallel sets for standard and color quickdraw.

if you're certain that all you want is bit depth then try:

short	bit_depth = 1;

if (theWorld.hasColorQD)	/* SysEnvirons, Gestalt may be better */
	bit_depth = (** (** GetGDevice()).gdPMap ).pixelSize;

this gets the bit depth of the current screen.  you can make similar calls
to get the bit depth of the "main screen" and the screen with the
maximum bit depth.  for more details on graphics device calls see:
Inside Macintosh Vol. 5, Chap. 5, Graphics Devices.

btw, in my experience, the major problem with moving to color windows
is checking for color QD before using routines like GetGDevice() and
NewCWindow().  it is real easy to forget this check (i know!).

the drawing routines usually work in either case but you can't use
new drawing routines, obviously, if color quickdraw isn't present.

  -dave-  
hairston@henry.ece.cmu.edu

jmunkki@hila.hut.fi (Juri Munkki) (03/29/91)

In article <1991Mar28.110336.40826@eagle.wesleyan.edu> rcook@eagle.wesleyan.edu writes:
>Here's the deal:  I have an old style window (ie not color, a standard
>grafport) and I do some color drawing in it with standard QuickDraw colors
>(by setting ForeColor and BackColor)  This works fine on a machine in 16 color
>mode or higher, but everything comes out black on a 2 or 4 color machine.  This
>is expected since standard QuickDraw isn't picky about how colors interact.
>
>Here's the problem:  I know how to sense if a machine has Color QuickDraw, but
>how do you detect the bit depth/color mode?  I don't want to move to color
>windows, because I want to keep only one set of drawing routines, thus not
>keeping parallel sets for standard and color quickdraw.

Someone else already gave a solution that uses GetGDevice. I'll just note
that GetGDevice gets you only one device and it might very well not be
the device that your window is using. Multiple screens getting very common
in these days and it's usual to have a large B&W screen and a smaller
color screen. What I usually do is that I put color windows on the smaller
screen. Some programs look at the current graphics device, see that it
is a B&W device and then refuse to draw in color.

The recommended method is to walk through the graphics device list with
calls to GetDeviceList and GetNextDevice. Find out if the device rectangle
intersects with your window and act accordingly.

There's another thing you should be aware of. Some Macs have color, but
not color quickdraw. You can actually buy 16-color boards for the SE and
they use the old color model for drawing.

I wrote a Prestel terminal emulator. Prestel happens to require those same
8 colors that are in the classic Macintosh selection. This program has a
check box that allows you to switch the colors on and off. This way the
user can choose what looks best.

One more way to get color with classic Macs is to print to an ImageWriter
II or LQ. These printers support the old color model with a special ribbon.
The results are quite pleasing. If you allow your user to copy a picture
to the clipboard, it should be possible to have it in color or in B&W
depending on what the user wants.

>Please help me out on this one.  At least I'm not asking about the sound
>manager (yet... :-)  Thanks.

Oh, the sound manager? I read the new and improved IM-VI chapter on the
sound manager and I was quite pleased. It is now much easier to understand
and things seem to work the way they should. Stereo sound is finally
possible and even easy to use. It looks like there are still some limitations
with the sampled sound synthesizer (I had to experiment to get rid of
a clicking sound).

The funny thing is that my program didn't crash while I was experimenting
with it, so I guess the new routines are much more robust than the old
ones.

The new sound manager uses slightly more CPU than the old sound driver, but
it is much more flexible. Some of you might remember my flames about the
sound manager, but now that it works, I find no reason for flaming.

   ____________________________________________________________________________
  / Juri Munkki	    /  Helsinki University of Technology   /  Wind  / Project /
 / jmunkki@hut.fi  /  Computing Center Macintosh Support  /  Surf  /  STORM  /
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

owen@sunfs3.Camex.COM (Owen Hartnett) (04/01/91)

What's the trick to eliminating the clicking in the sound manager?

-owen

lim@iris.ucdavis.edu (Lloyd Lim) (04/02/91)

In article <1991Mar29.153818.11510@santra.uucp> jmunkki@hila.hut.fi (Juri Munkki) writes:
>There's another thing you should be aware of. Some Macs have color, but
>not color quickdraw. You can actually buy 16-color boards for the SE and
>they use the old color model for drawing.

This is a problem.  I do the standard GetDevice/GetNextDevice/intersect window
loop to determine whether to use old-style colors or patterns.  There doesn't
seem to be any way to detect these old-style color boards except by using
device-specific routines (if they have some).  Am I missing anything?

+++
Lloyd Lim     Internet: lim@iris.eecs.ucdavis.edu
              America Online: LimUnltd
              Compuserve: 72647,660
              US Mail: 215 Lysle Leach Hall, U.C. Davis, Davis, CA 95616