TweetFollow Us on Twitter

Color Capable
Volume Number:3
Issue Number:7
Column Tag:Macintosh II

Lazy Man's Color

By Steven Sheets, Hoffman Estates, IL

Newsbreak....Cupertino, Calif.....Color is here!

The new Macintosh // computer has color capabilities. Most color video cards will allow up to 256 specific colors out of a possible color palatte of 16,777,216 selections. A new Color Quickdraw has been designed with Color Tables, Pixel Maps, Pixel Patterns, Color Icons, Color Grafports and Color Picture Handles to work with the new machine. Three new Managers have been added to facilitate color; the Color Manager, the Color Picker Package and the Palette Manager.

Are you ready to program with this new Color Quickdraw?

Before you answer that, did you know there was an alternative way to display color on the Mac? Use the old Quickdraw color routine! You didn’t know the older Quickdraw had color? Well...

Old Color

The original Macintosh displays were in black & white. 21,888 bytes of memory were used to display the normal 512 by 342 pixel screen (1 bit per pixel). However, the original Quickdraw had the capability to draw in color. In the original Grafport record, there were 2 fields (fgColor and bkColor) that determined the settings of the Foreground and Background color.

Quickdraw predefined 8 colors (Black, White, Red, Green, Blue, Cyan, Magenta and Yellow). Each color had a long integer constant associated with it. By passing these constants to the procedures ForeColor and BackColor, the respective fields of the current Grafport were changed. When any Grafport was created, the default settings for the Foreground and Background were Black and White respectively.

Color fields were treated similar to the more often used Pen Pattern (pnPat) and Background Pattern (bkPat). Any drawing by the Pen was done in the Foreground color, any Erasing was done in the Background color. Also Foreground and Background color affect the Copybits call. When copying a bitmap onto a Grafport, any bit that was set in the source Bitmap would make the corresponding pixel appear in the Foreground color on the Grafport. Any unset bit would make the pixel appear in the Background color.

However on the black and white Macintosh, any color other than white appears as black. Thus drawing Red on White, Blue on White, or even Yellow on White has the same effect on the Pre-Mac // computers; Black on White. Interestingly the Imagewriter // printer driver does use the color commands, thus making the Imagewriter // with a color ribbon the first color Macintosh output device of any type. While the new Mac // also has the new Color Quickdraw commands, it also supports the old commands, including the use of Foreground and Background color.

Fig. 1 Our program uses classic color options

Why Use Old?

There are several reasons for not wanting to use Color Quickdraw for your first color program. It might prove simpler, until you get a handle on Color Quickdraw (and the three associated managers), to use the older Quickdraw routines. Color Quickdraw involves new conceptional models, new data structures, and new routines. While it is well worth the effort to learn (the graphic effects are stunning), there is a stiff learning curve.

The Color Quickdraw manual is even larger than the original Quickdraw manual. That is assuming that you have the new documentation. Inside Macintosh Vol. V is due out soon, but unless you currently have a beta version, you will have to wait for APDA’s final release.

Even if you have the new documentation and routines, your development system may not implement the new ROM calls. Lightspeed C, Lightspeed Pascal, MDS do not support the new Quickdraw, while MPW has to be updated to version 2.0. Many programmers will have to wait until the developers of their programming language come out with a new update until they can use the new routines. Some lucky users can input all the new calls themselves and do not need the updates. That means typing in dozens of new calls and data structures (again assuming they have the documentation). Lucky them! [Apple is still working on the equates file and rumor has it the Pallette Manager is still changing. -Ed]

Finally there is the actual code size and time in involved programming the new Quickdraw. Color Quickdraw does take more code to implement and it’s data structures are larger. The simple ForeColor and BackColor routines take very little code space.

Certainly Color Quickdraw should be used if someone is writing a color Drawing program for the Mac //. But if you only wish to add color to your existing programs, using Color Quickdraw requires you to rewrite your code, redo your graphics and in some cases, even redo your complicated bitmaps. Placing ForeColor and BackColor calls before your existing code segments is much simpler. If your Program is intended to run on any Macintosh, the older Quickdraw may be all you need or want to produce color.

The Code

The source example is an extremely simple, standard Macintosh program. It loads and displays any MacPaint document in any of the eight Foreground and eight Background colors. A few notes:

1) The CWindow (which will display the MacPaint document) is centered on large screens (like a SuperMac monitor) or placed in the offset position.

2) The actual picture is stored in two sets of Bitmaps and Data handles. Data is stored this way since the size of a MacPaint bitmap is too large to store in 1 set (32K limit). If there is not enough memory to create the bitmaps, the program will state this and not allow a MacPaint document to be loaded

3) ForeC and BackC store the selected menu number (1-8), not the predefined Color constant. GetColor is used to convert the menu number into the color constant.

4) DoColor is the pivotal procedure; it sets the new Foreground/Background colors. Then it causes an window update so the window is redrawn in the new colors.

{Lazy Man’s Color by Steve Sheets 4/20/87 }
{Simple Demonstration of Mac // Color using the 
{ForeColor & BackColor of classical Quickdraw. }
{This program Loads and displays a MacPaint document }
(in any 2 colors.}


{Various Constants:Menu ID Numbers, Window Size, }
{Window Placement, BitMap Size and Number of Colors. }
 AppleMenuID = 300;
 FileMenuID = 301;
 EditMenuID = 302;
 ForeMenuID = 303;
 BackMenuID = 304;

 OffV = 40;
 OffH = 40;
 AboutH = 300;
 AboutV = 140;
 SizeH = 576;
 SizeV1 = 360;
 SizeV2 = 720;
 BitW = 72;
 NumSec = 2;

 XColor = 8;

{Various Variables:Menus, Bitmaps, Window, Colors, }
{Done Flag & Title Name }
 Done : boolean;
 AppleMenu, FileMenu: EditMenu, 
 ForeMenu, BackMenu : MenuHandle;

 CWindow : windowptr;
 CMap : ARRAY[1..NumSec] OF bitmap;
 CData : ARRAY[1..NumSec] OF handle;

 ForeC, BackC : integer;
 Title : str255;

{Given Color Number ( 1 to XColor, as selected by Menu), }
{returns actual longint Color Number (for ForeColor or }
{BackColor). }
FUNCTION GetColor (N : integer) : longint;
 1 : 
 GetColor := BlackColor;
 2 : 
 GetColor := WhiteColor;
 3 : 
 GetColor := RedColor;
 4 : 
 GetColor := GreenColor;
 5 : 
 GetColor := BlueColor;
 6 : 
 GetColor := CyanColor;
 7 : 
 GetColor := MagentaColor;
 8 : 
 GetColor := YellowColor;
 GetColor := WhiteColor;

{Sets new ForeColor & BackColor and forces an Update} 
{so Window is redrawn in the new colors. }
PROCEDURE DoColor (F, B : integer);
 count : integer;
 tempPort : Grafptr;
 IF F <> ForeC THEN
 FOR count := 1 TO XColor DO
 CheckItem(ForeMenu, count, count = F);
 ForeC := F;
 IF B <> BackC THEN
 FOR count := 1 TO XColor DO
 CheckItem(BackMenu, count, count = B);
 BackC := B;

{ Loads MacPaint Picture in Bitmaps and displays it.}
 diskBlock = PACKED ARRAY[1..512] OF QDbyte;
 MyReply : SFReply;
 MyType : SFtypelist;
 tempPoint : point;
 count : longint;
 refNum, scanline, N : integer;
 error : OSErr;
 srcBuf : ARRAY[1..2] OF diskBlock;
 srcPtr, dstPtr : Ptr;
 tempPoint.v := 60;
 tempPoint.h := 60;
 MyType[0] := ‘PNTG’;
 SFGetFile(tempPoint, ‘’, NIL, 1, MyType, NIL, MyReply);
 IF MyReply.good THEN
 IF FSOpen(MyReply.fname, MyReply.vrefnum, refNum) = noErr THEN
 count := 512;
 error := FSRead(refNum, count, @srcBuf);
 count := 1024;
 error := FSRead(refNum, count, @srcBuf);
 srcPtr := @srcBuf;
 FOR N := 1 TO NumSec DO
 dstPtr := CData[N]^;
 FOR scanline := 1 TO SizeV1 DO
 UnpackBits(srcPtr, dstPtr, BitW);
 IF ord(srcPtr) > (ord(@srcBuf) + 512) THEN
 srcBuf[1] := srcBuf[2];
 count := 512;
 error := FSRead(refNum, count, @srcBuf[2]);
 srcPtr := pointer(ord(srcPtr) - 512);
 error := FSClose(refNum);
 DoColor(ForeC, BackC);

{Creates a Rectangle centered on Screen (if window }
{size is smaller then the screen) or starting at a }
{standard offset (if window size is larger then }
{screen). }
PROCEDURE CenterRect (VAR R : rect;
 H, V : integer);
 tempH : integer;
 IF H > Screenbits.bounds.right THEN
 tempH := OffH
 tempH := ((Screenbits.bounds.right - H) DIV 2);
 SetRect(R, tempH, OffV, H + tempH, V + OffV);

{Draws text, centered in a rectangle in the About}
{  Box window in a certain color with a certain }
{justification }
PROCEDURE DoLine (S : str255;
 H, Top, Bottom, J : integer;
 C : longint);
 tempInteger : integer;
 tempRect : rect;
 tempInteger := ((AboutH - H) DIV 2);
 SetRect(tempRect, tempInteger, Top, tempInteger + H, Bottom);
 TextBox(POINTER(ord(@S) + 1), LENGTH(S), tempRect, J);

{Displays About Box (in color) until someone presses } 
{the button down.}
 tempWindow : windowptr;
 tempRect : rect;
 tempStr : str255;
 CenterRect(tempRect, AboutH, AboutV);
 tempWindow := NewWindow(NIL, tempRect, ‘’, true, dBoxProc, POINTER(-1), 
false, 0);

 DoLine(CONCAT(Title, ‘ by Steve Sheets’), AboutH, 20, 39, teJustCenter, 
 DoLine(‘Sample Mac // Color Program’, AboutH, 40, 59, teJustCenter, 
 DoLine(‘This program uses the ForeColor and BackColor Quickdraw commands 
to display a MacPaint document in two colors.’, AboutH - 50, 60, AboutV, 
teJustLeft, RedColor);

 WHILE NOT button DO

{Standard main menu procedure that handles }
{menu selections.  Can show About Box, open Desk }
{Accessories, Load in MacPaint file, change }
{the Done Flag (so the program quits), handle} 
{edit commands (Cut,Copy,Paste,Clear), and change }
{Foreground or Background color of the picture.}
PROCEDURE MainMenu (tempResult : LONGINT);
 tempInteger : integer;
 tempBoolean : boolean;
 tempStr : STR255;
 tempInteger := LoWord(tempResult);
 CASE HiWord(tempResult) OF
 AppleMenuID : 
 IF tempInteger = 1 THEN
 GetItem(appleMenu, tempInteger, tempStr);
 tempInteger := OpenDeskAcc(tempStr);
 FileMenuID : 
 CASE tempInteger OF
 1 : 
 3 : 
 Done := true;
 EditMenuID : 
 tempBoolean := SystemEdit(tempInteger - 1);
 ForeMenuID : 
 IF (tempInteger > 0) AND (tempInteger <= XColor) THEN
 DoColor(tempInteger, BackC);
 BackMenuID : 
 IF (tempInteger > 0) AND (tempInteger <= XColor) THEN
 DoColor(ForeC, tempInteger);

{Setup for Menus, Window, Bitmaps,  Colors }
{settings, Title and Done flag.  }
 DD = PACKED ARRAY[1..32000] OF 0..255;
 PP = ^DD;
 HH = ^PP;
 tempStr : STR255;
 tempRect : rect;
 count : integer;
 tempLong : longint;
 tempH : HH;
 Title := ‘Lazy Man@s Color’;
 Title[9] := CHR(39);

 tempStr := ‘ ‘;
 tempStr[1] := CHR(appleMark);
 AppleMenu := NewMenu(AppleMenuID, tempStr);
 AppendMenu(AppleMenu, CONCAT(‘About ‘, Title, ‘...;(-’));
 AddResMenu(AppleMenu, ‘DRVR’);

 FileMenu := NewMenu(FileMenuID, ‘File’);
 AppendMenu(FileMenu, ‘Load MacPaint Documents/L;(-;Quit/Q’);

 EditMenu := NewMenu(EditMenuID, ‘Edit’);
 AppendMenu(EditMenu, ‘Undo/Z;(-;Cut/X;Copy/C; Paste/V;Clear’);

 ForeMenu := NewMenu(ForeMenuID, ‘Set Foreground’);
 AppendMenu(ForeMenu, ‘Black;White;Red;Green;Blue; Cyan;Magenta;Yellow’);

 BackMenu := NewMenu(BackMenuID, ‘Set Background’);
 AppendMenu(BackMenu, ‘Black;White;Red;Green;Blue;Cyan; Magenta;Yellow’);

 InsertMenu(AppleMenu, 0);
 InsertMenu(FileMenu, 0);
 InsertMenu(EditMenu, 0);
 InsertMenu(ForeMenu, 0);
 InsertMenu(BackMenu, 0);


 CenterRect(tempRect, SizeH, SizeV2);
 CWindow := NewWindow(NIL, tempRect, Title, true, 4, POINTER(-1), false, 

 CMap[1].rowBytes := BitW;
 SetRect(CMap[1].bounds, 0, 0, SizeH, SizeV1);
 CData[1] := NewHandle(BitW * SizeV1);
 IF CData[1] <> NIL THEN
 tempH := HH(CData[1]);
 FOR count := 1 TO BitW * SizeV1 DO
 tempH^^[count] := 0;
 CMap[2].rowBytes := BitW;
 SetRect(CMap[2].bounds, 0, SizeV1, SizeH, SizeV2);
 CData[2] := NewHandle(BitW * SizeV1);
 IF CData[2] <> NIL THEN
 tempH := HH(CData[2]);
 FOR count := 1 TO BitW * SizeV1 DO
 tempH^^[count] := 0;
 IF (CData[1] = NIL) OR (CData[2] = NIL) THEN
 SetWTitle(CWindow, ‘Not Enough Memmory’);
 DisableItem(FileMenu, 1);
 ForeC := 0;
 BackC := 0;
 DoColor(1, 2);
 Done := false;

{Standard main program loop that handles all }
{events (ie. mouse down, key downs & updates) until }
{the Done flag is set.  }
 tempEvent : EventRecord;
 tempWindow : windowptr;
 tempCode : integer;
 tempPort : Grafptr;
 tempRect : rect;
 IF GetNextEvent(everyEvent, tempEvent) THEN
 CASE tempEvent.what OF
 mouseDown : 
 tempCode := FindWindow(tempEvent.where, tempWindow);
 CASE tempCode OF
 inDrag, inContent : 
 IF tempWindow <> FrontWindow THEN
 IF Cwindow = tempWindow THEN
 IF CWindow <> FrontWindow THEN
 SetRect(tempRect, -25000, -25000, 25000, 25000);
 DragWindow(CWindow, tempEvent.where, tempRect);
 inMenuBar : 
 inSysWindow : 
 SystemClick(tempEvent, tempWindow);
 END; { of tempCode case }
 END; { of mouseDown }
 keydown, autoKey : 
 IF BitAnd(tempEvent.modifiers, cmdKey) <> 0 THEN
 MainMenu(MenuKey(CHR(tempEvent.message MOD 256)));
 updateEvt : 
 IF CWindow = WindowPtr(tempEvent.message) THEN
 IF CData[1] <> NIL THEN
 CMap[1].baseAddr := CData[1]^;
 CopyBits(CMap[1], CWindow^.portBits, CMap[1].bounds, CMap[1].bounds, 
srcCopy, NIL);
 IF CData[2] <> NIL THEN
 CMap[2].baseAddr := CData[2]^;
 CopyBits(CMap[2], CWindow^.portBits, CMap[2].bounds, CMap[2].bounds, 
srcCopy, NIL);
 UNTIL Done;

{***PROGRAM*** }
Apple Inc.
Microsoft Corpora
Google Inc.

MacTech Search:
Community Search:

Software Updates via MacUpdate

BBEdit 11.0.2 - Powerful text and HTML e...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more
ExpanDrive 4.2.1 - Access cloud storage...
ExpanDrive builds cloud storage in every application, acts just like a USB drive plugged into your Mac. With ExpanDrive, you can securely access any remote file server directly from the Finder or... Read more
Adobe After Effects CC 2014 13.2 - Creat...
After Effects CC 2014 is available as part of Adobe Creative Cloud for as little as $19.99/month (or $9.99/month if you're a previous After Effects customer). After Effects CS6 is still available... Read more
Command-C 1.1.7 - Clipboard sharing tool...
Command-C is a revolutionary app which makes easy to share your clipboard between iOS and OS X using your local WiFi network, even if the app is not currently opened. Copy anything (text, pictures,... Read more
Tidy Up 4.0.2 - Find duplicate files and...
Tidy Up is a complete duplicate finder and disk-tidiness utility. With Tidy Up you can search for duplicate files and packages by the owner application, content, type, creator, extension, time... Read more
Typinator 6.3 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more
GraphicConverter 9.5 - Graphics editor w...
GraphicConverter is an all-purpose image-editing program that can import 200 different graphic-based formats, edit the image, and export it to any of 80 available file formats. The high-end editing... Read more
Toast Titanium 12.0.1 - The ultimate med...
Toast Titanium goes way beyond the very basic burning in the Mac OS and iLife software, and sets the standard for burning CDs, DVDs, and now Blu-ray discs on the Mac. Create superior sounding audio... Read more
QuickBooks 2015 R3 - Financi...
Save 20% on QuickBooks Pro for Mac today through this special discount link QuickBooks Pro 2013 helps you manage your business easily and efficiently. Organize your finances all in one place, track... Read more
Remotix 3.0.6 - Access all your computer...
Remotix is a fast and powerful application to easily access multiple Macs (and PCs) from your own Mac. Features: Complete Apple Screen Sharing support - including Mac OS X login, clipboard... Read more

Latest Forum Discussions

See All

Dragon Quest III Review
Dragon Quest III Review By Jennifer Allen on December 18th, 2014 Our Rating: :: DATED BUT NOT WITHOUT MERITUniversal App - Designed for iPhone and iPad A walk down memory lane isn’t foolproof for Dragon Quest III, but it has its... | Read more »
8 KEMCO JRPGs Are Just $0.99 in Celebrat...
8 KEMCO JRPGs Are Just $0.99 in Celebration of the Holidays Posted by Jessica Fisher on December 18th, 2014 [ permalink ] KEMCO has announc | Read more »
Brothers in Arms 3: Sons of War Review
Brothers in Arms 3: Sons of War Review By Jennifer Allen on December 18th, 2014 Our Rating: :: FUN BUT PUSHYUniversal App - Designed for iPhone and iPad Brothers in Arms 3: Sons of War could be great fun, but its plethora of... | Read more »
The Snow is Falling on the French Countr...
The Snow is Falling on the French Countryside of Carcassonne’s Newest Update Posted by Jessica Fisher on December 18th, 2014 [ permalink ] < | Read more »
Creatures Such As We Review
Creatures Such As We Review By Jennifer Allen on December 18th, 2014 Our Rating: :: INTERESTING DISCUSSIONSUniversal App - Designed for iPhone and iPad Taking a more sedate approach to interactive fiction, Creatures Such As We... | Read more »
Stair: Slide the Blocks to Ascend (Game...
Stair: Slide the Blocks to Ascend 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Slide the blocks to ascend! Stair: Slide the Blocks to Ascend | Read more »
Give It Up! (Games)
Give It Up! 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: GIVE IT UP is a rather hard game where you have to assist this cheerful, singing Blob in jumping through 9 different tracks.So far... | Read more »
The Drive : Devil's Run (Games)
The Drive : Devil's Run 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: ON THE ROAD AGAIN! The Drive - Devil’s Run is classic point to point style racing game that pays homage to the classics... | Read more »
Procreate Pocket (Entertainment)
Procreate Pocket 1.01 Device: iOS iPhone Category: Entertainment Price: $2.99, Version: 1.01 (iTunes) Description: Create - anytime, anywhere. Made by the developers of the award-winning Procreate® for iPad®, Procreate Pocket™ allows... | Read more »
IRON FINGER - Mini Games Championship (...
IRON FINGER - Mini Games Championship 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Quick to play, easy to learn yet hard to master.. TAP, SWIPE & TILT your way through mini games that... | Read more »

Price Scanner via

KMI MIDI K-Board Great Gift for Amateur &...
The K-Board is a MIDI Nano keyboard for music creation for iPad, Android, And computers; the easiest way to make music with iPads & Android tablets, and Mac, Windows, or Linux computers. Ultra-... Read more
Amazon offers 15-inch 2.2GHz Retina MacBook P... has the 15″ 2.2GHz Retina MacBook Pro on sale for $1699 including free shipping. Their price is $300 off MSRP. Stock is limited, so act now if you’re interested. Read more
Holiday sales continue: MacBook Pros for up t...
 B&H Photo has new MacBook Pros on sale for up to $300 off MSRP as part of their Holiday pricing. Shipping is free, and B&H charges NY sales tax only: - 15″ 2.2GHz Retina MacBook Pro: $1699... Read more
Google Search App For iOS Gets A Major Makeov...
Google has given iOS users an early Christmas present with a substantial update of it’s not-very-often-upgraded Google Search app. Google Search has been my go-to tool for Web searches since it was... Read more
ShopKeep Apple Pay And Chip Card Reader Avail...
ShopKeep, a cloud-based technology provider to more than 10,000 small business owners to manage retail shops and restaurants with iPads, has released its new Apple Pay and chip card reader. This... Read more
Holiday sale! 27-inch 5K iMac for $2299, save...
 B&H Photo has the 27″ 3.5GHz 5K iMac in stock today and on sale for $2299 including free shipping plus NY sales tax only. Their price is $200 off MSRP, and it’s the lowest price available for... Read more
Holiday Sale! 3.7GHz Quad Core Mac Pro availa...
 B&H Photo has the 3.7GHz Quad Core Mac Pro on sale for $2599 including free shipping plus NY sales tax only. Their price is $400 off MSRP, and it’s the lowest price for this model from any... Read more
iPhone 6 Number 3 Canadian Google Search Of 2... reports that Apple’s iPhone 6 was the third highest-trending Google Canada search topic of 2014, exceeded only by Robin Williams largely after his death by suicide in August, and the FIFA... Read more
New iPad mini 3 Counter-Top & Wall Mount...
newMacgadgets has announced new secure all-acrylic displays for the iPad mini 3 (also works fine with the mini 2, last year’s iPad mini With Retina Display, and the original iPad mini). The new iPad... Read more
Holiday sales continue, MacBook Airs for up t...
B&H Photo has 2014 MacBook Airs on sale for up to $120 off MSRP, for a limited time, for the Thanksgiving/Christmas Holiday shopping season. Shipping is free, and B&H charges NY sales tax... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.