[comp.sys.mac.programmer] Automatic screen depth changes

swalker@uhunix1.uhcc.Hawaii.Edu (Sunny Walker) (12/11/90)

Reply via e-mail please.

Are there any brilliant Mac programmers out there that are willing to share
some code (for Think C 3.0, Think Pascal 1.0, or Turbo Pascal 1.1) that
change the screen depth (i.e. from 256 colors to 2 black & white and vice
versa) without going through the Control Panel?  I have too many CDEVs and
would rather just have my programs change the depth automatically.  I know
MacroMind Director changes the screen depth, so I know it can be done.

Thanks in advance...
SW

-------------------------------------------------------------------------
| Sunny Walker, Xevian Technology             | "It is reality that     |
| swalker@uhunix1.uhcc.Hawaii.Edu (preferred) |  reality is illusion."  |
| swalker@uhccvx.uhcc.hawaii.edu              |     -- Monty Python     |
-------------------------------------------------------------------------
| "Witticism, n. A sharp and clever remark, usually quoted, and seldom  |
|  noted; what the Philistine is pleased to call a `joke.'" - A. Bierce |
-------------------------------------------------------------------------

lemke@radius.com (Steve Lemke) (12/12/90)

swalker@uhunix1.uhcc.Hawaii.Edu (Sunny Walker) writes:

>Reply via e-mail please.
(I'll email this to you also, but I thought that the net might be interested.)

>Are there any brilliant Mac programmers out there that are willing to share
>some code (for Think C 3.0, Think Pascal 1.0, or Turbo Pascal 1.1) that
>change the screen depth (i.e. from 256 colors to 2 black & white and vice
>versa) without going through the Control Panel?  I have too many CDEVs and
>would rather just have my programs change the depth automatically.  I know
>MacroMind Director changes the screen depth, so I know it can be done.

I think I can help you here, and also provide some useful information to
the net at large.  See the code that follows.  If you have questions, ask...

Disclaimer:  I pasted some of this code, and typed the rest.  I do not
guarantee that it will even compile, but it should give you enough to
go on.  For more information, see Tech Note 276: "Gimmie Depth or Gimmie
Death".

Important!! BE CAREFUL WITH HasDepth - there are a few minor problems
with it.  Basically on a CPU with 32-bit QuickDraw in ROM (presently only
the IIci, IIfx, and IIsi), it will NOT return the video mode, but rather
it will only return a boolean ($FF) true if the desired mode is found.
Another more serious problem is that each time you call it, it leaves
several non-relocatable blocks in the system heap, each of size $2A.
The number of blocks it leaves is higher for each "deeper" mode you ask
about.  The end result is that if you check each mode (1,2,4,8,16,24),
you end up with about .5K up heap space eaten up.  If you do this enough,
you can end up in deep trouble.  I no longer use HasDepth because of
this problem.  It has been reported to MacDTS.

--------------------- THINK Pascal code sample starts here -------------
function SetDepth (gd: GDHandle;
                   newDepth, whichFlags, newFlags: Integer): Integer;
    inline
        $203C, $000A, $0013, $AAA2;   { Move.L #$000A0013,D0 }
                                      { _PMgrDispatch }

function HasDepth (gd: GDHandle;
                   newDepth, whichFlags, newFlags: Integer): Integer;
    inline
        $203C, $000A, $0014, $AAA2;   { Move.L #$000A0014,D0 }
                                      { _PMgrDispatch }

function ChangeMode(toColor:Boolean): Integer;
var
    savePort: GrafPtr;
    myGD: GDHandle;
begin
    GetPort(savePort);     {save the current grafPort}
    {SetDepth may (and probably WILL) change the current grafPort to the}
    {window manager's grafPort.  Thus, we should save and restore it.}
    myGD := GetMainDevice; {or substitute whatever GDevice you want to set}
    if toColor then
        ChangeMode := SetDepth(myGD, 8, 1, 1)
    else
        ChangeMode := SetDepth(myGD, 1, 1, 0);
    SetPort(savePort);     {restore the original grafPort}
end;


>Thanks in advance...

No problem!

--Steve
-- 
----- Steve Lemke, (now in) Software Engineering, Radius Inc., San Jose -----
----- "I'm not a UNIX wizard, but I play the Postmaster at radius.com." -----
----- Reply to: lemke@radius.com    (radius!lemke@apple.com works too!) -----

kimberly (Kimberly Gregory) (12/15/90)

I would like to obtain a free "shareware" ANSI Fortran compiler
(and accompanying documentation, if any).

Please respond to:  kimberly@mdi.com

Thank you, Kimberly Cochran Gregory @ MDI in Bothell, WA