develop-09 9201 Winter 1992
From the originals
13 scansMachine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.
These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.
Image 1
develop The Apple Technical Journal MAKING THE MOST OF COLOR ON 1-BIT DEVICES THE TEXTBOX YOU'VE ALWAYS WANTED MAKING YOUR MACINTOSH SOUND LIKE AN ECHO BOX SIMPLE TEXT WINDOWS VIA THE TERMINAL MANAGER TRACKS: A NEW TOOL FOR DEBUGGING DRIVERS USING THE PALETTE MANAGER OFF-SCREEN BACKGROUND-ONLY APPLICATIONS IN SYSTEM 7 MACINTOSH Q & A APPLE II Q & A NEWFEATURE: KON & BAL'S PUZZLE PAGE Issue 9 Winter 1992 Apple Computer, Inc.
A pixelated, dithered color photograph of a red apple with a bite taken from it, set in a square image on the left beside a stacked list of article titles on the right.
Reading notes: Dithered image makes the apple's exact details uncertain, though it is not text. Headline 'develop' is in large spaced lowercase letters, and the subtitle line is spaced letter by letter; spacing may be approximate.
- Printed dates
- Winter 1992
- Languages
- English
PDF page 1
d e v e l o p T h e A p p l e T e c h n i c a l J o u r n a l MAKING THE MOST OF COLOR ON 1-BIT DEVICES THE TEXTBOX YOU’VE ALWAYS WANTED MAKING YOUR MACINTOSH SOUND LIKE AN ECHO BOX SIMPLE TEXT WINDOWS VIA THE TERMINAL MANAGER TRACKS: A NEW TOOL FOR DEBUGGING DRIVERS USING THE PALETTE MANAGER OFF-SCREEN BACKGROUND-ONLY APPLICATIONS IN SYSTEM 7 MACINTOSH Q & A APPLE II Q & A NEWFEATURE: KON & BAL’ S PUZZLE PAGE I ssue 9 Winter 1992 Apple Computer, Inc.
Reading notes: Headline was set to null because the supplied copy is a list of article titles rather than one primary headline. Visual layout was not verified from an image; the visual description is inferred only from the supplied copy. Spaced-out letters in the masthead line 'd e v e l o p T h e A p p l e T e c h n i c a l J o u r n a l' and 'I ssue 9' may reflect extraction spacing rather than print. 'NEWFEATURE:' appears without a space in the supplied copy and may be a line-break artifact. 'KON & BAL’ S' has a space before the S in the supplied copy and may be an extraction artifact. No advertised products or prices appear in the supplied copy.
- Printed dates
- Winter 1992
- Languages
- English
PDF page 2
E D I T O R I A L S T A F F Editor-in-Cheek Caroline Rose Technical Buckstopper Dave Johnson Review Board Pete “Luke” Alexander, Chris Derossi, C. K. Haun, Larry Rosenstein, Andy Shebanow, Gregg Williams Managing Editor Monica Meffert Assistant Managing Editor Ana Wilczynski Contributing Editors Lorraine Anderson, Toni Haskell, Judy Helfand, Rebecca Pepper, Rilla Reynolds, Leslie Steere, Carol Westberg Indexer Ira Kleinberg Manager, Developer Support Systems and Communications David Krathwohl A R T & P R O D U C T I O N Production Manager Hartley Lesser Art Director Diane Wilcox Technical Illustration Geoff McCormack, John Ryan Formatting Forbes Mill Press Printing Wolfer Printing Company, Inc. Film Preparation Aptos Post, Inc. Production PrePress Assembly Photography Sharon Beals, Dennis Hescox, Kathleen Siemont Circulation Management David Wilson Online Production Cassi Carpenter develop, The Apple Technical Journal, is a quarterly publication of the Developer Support Systems and Communications group. To create this cover, Hal Rucker and Cleo Huggins bought the nicest-looking fruit they could find, photographed it and scanned in a slide, manipulated the scan with Adobe Photoshop, and blended in a dithered version of it. Delicious! The Developer CD Series disc for February 1992 or later contains this issue and all back issues of develop along with the code that the articles describe. The contents of this disc, which includes other handy software and documentation, can also be found on AppleLink.
Reading notes: Transcript is intentionally empty because exact text is preserved separately; the other fields were filled only from the supplied copy and not verified against the scan. No headline is present in the supplied copy, so headline is null. The supplied copy is a masthead and colophon rather than an advertisement, so productNames include only items named as promoted or referenced. Puns such as "Editor-in-Cheek" and "Technical Buckstopper" are printed as written. Reading order of the staff credits block and the colophon paragraphs cannot be confirmed from the supplied text alone; the credits are listed in two-column-style line breaks. The visual layout, including any cover artwork, cannot be checked against the scan from the supplied text.
- Printed product names
- develop, The Apple Technical Journal · Developer CD Series · AppleLink · Adobe Photoshop
- Printed dates
- February 1992
- Languages
- English
PDF page 3
CONTENTS Winter 1992 1 © 1992 Apple Computer, Inc. All rights reserved. Apple, the Apple logo, APDA, Apple IIGS, AppleLink, AppleShare, AppleTalk, EtherTalk, GS/OS, ImageWriter, LaserWriter, LocalTalk, MacApp, Macintosh, MPW, MultiFinder, and TokenTalk are trademarks of Apple Computer, Inc., registered in the U.S. and other countries. A/ROSE, Balloon Help, develop, Finder, Macintosh Coprocessor Platform, Macintosh Quadra, QuickDraw, QuickTime, SNA•ps, Sound Manager, Tools Advisor, and TrueType are trademarks of Apple Computer, Inc. HyperCard is a registered trademark of Apple Computer, Inc. licensed to Claris Corp. Adobe Photoshop and PostScript are registered trademarks of Adobe Systems Inc. MacWrite is a registered trademark of Claris Corp. CompuServe is a registered trademark of CompuServe, Inc. Internet and VAX are trademarks of Digital Equipment Corp. IBM is a registered trademark of International Business Machines Corp. Linotronic is a trademark, and Helvetica and Times are registered trademarks, of Linotype Company. Microsoft is a registered trademark of Microsoft Corp. Nisus is a trademark of Paragon Concepts, Inc. Sony is a registered trademark of Sony Corporation. NuBus is a trademark of Texas Instruments. UNIX is a registered trademark of UNIX System Laboratories, Inc. We want your two cents! 2 Your praise and your scorn. 4 Making the Most of Color on 1-Bit Devices by Konstantin Othmer and Daniel Lipton A two-part article: how to create color PICTs on black-and-white machines, and the theory and practice of dithering. 7 The TextBox You’ve Always Wanted by Bryan K. (“Beaker”) Ressler Here’s a replacement for TextBox, with better performance, more flexibility, and international compatibility. What more do you want? 31 Making Your Macintosh Sound Like an Echo Box by Rich Collyer Learn how to use double buffering techniques to simultaneously record and play sounds. 48 Simple Text Windows via the Terminal Manager by Craig Hotchkiss The Terminal Manager (in the Communications Toolbox) provides handy text output capabilities in your application with virtually no effort. 60 Tracks: A New Tool for Debugging Drivers by Brad Lowe Debugging device drivers is a pain. This tool provides an easy way to log information from your driver, greatly easing your debugging woes. 68 Graphics Hints From Forrest: Using the Palette Manager Off-Screen by Forrest Tanaka Can you use the Palette Manager to manage colors in off- screen ports? Well, yes, but there are some caveats. 29 Be Our Guest: Background-Only Applications in System 7 by C. K. Haun Faceless background tasks provide a handy way out of some sticky situations. C. K. shows you the basics. 58 The Veteran Neophyte: Silicon Surprise by Dave Johnson Computers are not only great for studying complex systems, they are complex systems. Or at least Dave thinks so. 82 KON & BAL’s Puzzle Page: It’s Just a Computer by Konstantin Othmer and Bruce Leak Are there demons in Kon’s computer? Or is it just a simple mistake? A debugging puzzle to tickle your brain. 103 Answers to your product development questions. Macintosh Q & A 85 Apple II Q & A 100 106 E D I T O R I A L L E T T E R S A R T I C L E S C O L U M N S Q & A I N D E X
Reading notes: Page numbers and layout cues in the table of contents are ambiguous in reading order.
- Printed dates
- 1992 · © 1992
- Languages
- English
PDF page 4
Dear Readers, Let’s talk about develop : what it is, what it might be, what it can do for you, and what you can do for it. This journal exists to meet your needs, so I hope you’ll help us out by reading on and giving us your two cents (if not your articles). Originally, develop was thought of as “heavily commented code”: along with the accompanying CD, it was meant as a vehicle for providing well-explained code that you, the developer, could plug into your application with the confidence that it would be compatible with future system software. To ensure compatibility, articles and code were written primarily by Apple engineers and heavily reviewed by other engineers at Apple. But other types of articles have been submitted, and some have made it into print. Most notable was the ground-breaking Threads article in Issue 6, the first article for which source code was not provided. This lack of source code did not go unnoticed by our readers, yet the overall response to the Threads package was extremely favorable. So we’ve moved from always providing source code to providing it if at all possible . We still make every effort, however, to give you something that won’t break in future systems. Recently we’ve had some requests to publish articles that describe algorithms or ideas, not code. Our current feeling is that as long as an article can help you create good Apple products, we’ll consider publishing it. Please let us know what you’d like to see. There are some Apple engineers who are willing to contribute to develop but would like to know just what developers want to see. We get a lot of input from Developer Technical Support about what you seem to need the most help with—but let us at develop know directly, and we can try to make it happen faster. Regarding who writes the articles: we feel that as long as the code is reviewed by Apple engineers, there’s no need to rely solely on people at Apple for contributions. We’d like to encourage all of you to think about what you’d like to share with your fellow developers—something that would help them and also give you a way to showcase and release your code in a way that wouldn’t otherwise be possible. We offer something those other journals don’t: not only review by Apple engineers and the assurance of future compatibility, but also an editorial process that will make your prose shine so brilliantly you’ll need to wear shades. We’ll assign an editor who will d e v e l o p Winter 1992 CAROLINE ROSE (AppleLink: CROSE) has been writing computer documentation ever since Steve Jobs was barely a teen. When his company moved in down the block from where she worked as a writer and then a programmer, Caroline took no notice—until they asked if she wanted to write what even then was known as Inside Macintosh. Around the time she completed that three-volume tome, Steve left Apple to form NeXT, and Caroline signed on to launch NeXT’s Publications group. A year ago she returned to Apple to take on the fun- filled job of being develop’s editor in chief. For fun outside of work, Caroline dances up a storm, listens to music, plays with her cat and other friends, treks through the wilderness (in boots or on skis), swims like a maniac, reads fiction (not sci-fi!), studies Italian, does Tai Chi, and never stops exploring new ways to have fun.• 2 CAROLINE ROSE
Reading notes: Spaced-out letters in the source text (e.g. 'd e v e l o p') may affect exact product name spelling. Reading order of the sidebar author bio relative to the main text is uncertain.
- Printed product names
- develop · Inside Macintosh · NeXT
- Printed dates
- Winter 1992
- Languages
- English · Italian
PDF page 5
help turn your raw material into a polished piece—or tread lightly on it if that’s all you need. We’ll give your article that professional look and feel without killing the humor. So, if you’re willing, please send me your ideas or outlines, and we’ll take it from there. Back to the subject of your opinions about develop : Many of you who are Apple Associates and Partners have by now been formally surveyed on how you rate various support-related materials, of which develop is only one shining example. We’d also like to hear from the rest of you, however informally. I can’t overemphasize how important your opinions are and how much they’ll affect develop ’s future. So please, express yourself! Tell us what’s good or bad about this journal’s content, format, delivery, or anything else. We’re all ears. Issue 8 ended with this trivia question: What word was used instead of “click” to describe the action of pressing a button on that first mouse? The answer, which none of you have gotten as of this writing, is “bug.” Maybe you’ll do better on this next one: The original hardcover Inside Macintosh Volumes I-III had a running pattern of Macintosh computers across its endpapers (those heavy sheets at the very beginning and end of hardcover books). What broke this pattern, and why? EDITORIAL Winter 1992 3 SUBSCRIPTION INFORMATION Use the order form on the last page of this issue to subscribe to develop. Please address all subscription-related inquiries to develop, Apple Computer, Inc., P.O. Box 531, Mt. Morris, IL 61054 (or AppleLink DEV.SUBS).• BACK ISSUES For information about back issues of develop and how to obtain them, see the reverse of the order form on the last page of this issue. Back issues are also on the Developer CD Series disc.• Caroline Rose Editor
Reading notes: Source appears to be a fragment excerpt; reading order across column breaks is uncertain. Heading for the primary section is not clearly identified in the supplied copy.
- Printed product names
- develop · Inside Macintosh
- Printed dates
- Winter 1992
- Languages
- English
PDF page 6
CURLING UP WITH DEVELOP Regarding your editorial in Issue 8: I agree with you on liking to have a “hard copy” to be able to curl up with when trying to understand something for the first time. I can always go to the computer and try examples or ideas. But to lay back and put up my feet or nestle under a quilt in bed is more relaxing to let concepts sink in and develop on their own, to spring forth with clarity later. I like the idea of sending the disc separately in its own case—though I never had a mangled disc problem. It is the magazine itself that has a rougher trip. I received Issue 8 without the disc and hope that the disc is not far behind. The mailing label on the back cover was half off, not torn, but detached. Flapping in the breeze, so to speak. Keep up the good work on the magazine. I look forward to it each time. —Robert Redmond Thanks for your letter. It’s not only heartening to hear from developers who agree with me on this, but it makes a difference. Your opinions do count. The disc is now in a separate case, but it’s not mailed under a separate label. They should have arrived wrapped cozily together. We’ll send you the disc right away. Sorry about that. —Caroline Rose TEXT FORMATS GALORE There’s a problem with the Macintosh Technical Notes which I’m finding with increasing frequency in Apple’s electronic publications. The only word processor I use is Nisus, with which I can read MS Word 3.0 and 4.0 files without buying a Microsoft product. This may be an unreasonable prejudice, but I bet it isn’t uncommon. But Nisus can’t decipher fast-saved Word files. This means, I suspect, that the entire set of new Macintosh technical publications is unavailable to me. Worse, I fear that the next Developer CD is going to have lots of files with new, valuable, and (for me) hidden information. I know Apple is serious about electronic distribution of technical documents. I’m sure fast-saving in Word is a great convenience to the authors, but surely using a format not widely readable defeats the purpose of the exercise. I don’t object to standardizing on Word 3.0 or 4.0, so long as that format—and not Microsoft’s convenience variant—is actually used. Could you please ask your authors, when providing documents for publication, to use an accessible format? —Fritz Anderson Thank you for alerting us to this problem. It was a snafu on our part. None of the files should have been fast-saved in Word. We know that having text documents in Word and MacWrite® represents a bias toward these products. Unfortunately our alternatives are limited and we’ll probably have to continue using these products until the spring. The good news is that we’re working on a new text formatting tool. This tool will be available on the CD and will be able to open, search, and print text documents available on the CD. The dilemma of how d e v e l o p Winter 1992 PLEASE WRITE! We welcome timely letters to the editors, especially from readers reacting to articles that we publish in develop. Letters should be addressed to Caroline Rose (or, if technical develop-related questions, to Dave Johnson) at Apple Computer, Inc., 20525 Mariani Avenue, M/S 75-2B, Cupertino, CA 95014 (AppleLink: CROSE or JOHNSON.DK). All letters should include your name and company name as well as your address and phone number. Letters may be excerpted or edited for clarity (or to make them say what we wish they did). • 4 LETTERS
Reading notes: Letter text 'with a few characters and symbols' in the 'Text Formats Galore' section is cut off mid-sentence at 'how'. Reading order between the two letters and the editor replies is inferred from layout and may be uncertain.
- Printed product names
- Nisus · MS Word 3.0 · Word · MacWrite · Developer CD
- Printed dates
- Winter 1992 · Issue 8
- Languages
- English
PDF page 7
to make every document available to every developer has been a topic of discussion for some time. We’re hoping this will solve the problem. Again, thank you for your input. Developer feedback is the fuel of change around here. Keep it coming. —Sharon Flowers NEW AND IMPROVED CD I just received Issue 8 of develop , and was pleased to find that the developer’s CD has improved. Is this new? —Mike Caputo Yes, starting with Issue 8 the CD is not just Developer Essentials, but the entire Developer CD Series disc (of which Developer Essentials is just a subset). —Caroline Rose SUBMITTING TO DEVELOP First of all, I’d like to say that I’m a big fan of develop . The combination of excellent technical articles (with required humor) and a CD-ROM of other developer materials is unmatched. At least the flak surrounding the CD- ROM has finally calmed down in the Letters section. I’ve always liked the idea from the start even though I purchased a CD-ROM drive only last week. I’m writing to find out if develop accepts articles from non-Apple employees. I haven’t looked through the back issues to see if there were any, but none come to mind. If so, do you have a style guide for writing articles? Keep up the great work! —Paul-Marcel St-Onge Thank you for your kind words about develop ; it’s always a pleasure to receive mail from a big fan. Yours is the type of letter that editors in chief dream of. We do indeed accept articles from non-Apple employees (see this issue’s Editorial). We have a vast array of materials ready for prospective authors, including an introductory document, a short submission form, a set of detailed author’s guidelines, and even a Microsoft Word template for entering your article in a develop -like format. We’ll start with the intro and then send the rest as you need it. On the subject of the CD-ROM controversy, it may experience a revival as a result of Apple’s dropping printed develop and Tech Notes from the monthly mailing to Associates and Partners. We’d like to hear what developers think about that. —Caroline Rose ART ILLEGIBLE ON-LINE Figure 1 from Michael Gough’s article on Futures (Issue 7) was illegible when printed under System 7 from a Macintosh II on a LaserWriter IINTX. It’s just as illegible on the screen. Any ideas? The HyperCard® format on the CD is convenient for flipping to pages and articles but is terrible for seeing all of a page at one time, since HyperCard’s windows are not resizable. Further- more, HyperCard is slow—especially from a CD. And searching is neither fast nor intuitive. —Steve Tyler LETTERS Wnter 1992 5
Reading notes: Section heading 'LETTERS' and 'Wnter 1992' footer appear as running header/footer; reading order of letters is linear and clear. Heading 'SUBMITTING TO DEVELOP' and other letter subheadings are letter titles rather than a primary headline.
- Printed product names
- HyperCard · LaserWriter IINTX · Macintosh II · System 7 · Microsoft Word · develop · Developer Essentials · Developer CD Series
- Printed dates
- Issue 8 · Issue 7
- Languages
- English
PDF page 8
I looked into the problem and found out that a mistake was made when the electronic version of Issue 7 was created: Art that’s in EPS format is normally opened in an application that interprets PostScript® and then saved as a PICT. This process wasn't followed, with the result that the conversion to PICT was only an approximation, and so not very legible. This will be fixed in Issue 7 on the CD. Regarding the HyperCard format, a lot of people agree with you. We’re working on an alternate viewing mechanism—but this mechanism may not apply to develop for a while yet. Meanwhile, HyperCard’s windows are in fact resizable. If you’re not able to resize them, your memory partition for HyperCard is probably not large enough; try increasing it. —Caroline Rose d e v e l o p Winter 1992 You can obtain a copy of the Tools Advisor through APDA. The disk-based version can also be found on the Developer CD Series disc. To use the Tools Advisor, you’ll need a Macintosh with System 6.0.5 or later, HyperCard 2.0 or later, and a hard disk. To use the CD-ROM version, you’ll of course also need a CD-ROM drive. • 6 To a Macintosh developer starting a new project, the range of equipment available can seem daunting. To an experienced engineer suffering the constant barrage of catalogs, technical brochures, and advertisements, it can feel safest to hang on to familiar tools, whatever their shortcomings. But what’s available? What systems or tools might help you get your project done? Developer University has released the Macintosh Development Tools Advisor to help answer these questions. The Tools Advisor offers a broad array of information. A hypertext system, it tailors the data it presents to your particular interests and demands. The Advisor incorporates comprehensive technical data on over 80 programming tools—compilers and languages, debuggers and prototypers, CASE tools, and multimedia packages. It also includes essays on critical topics such as object-oriented programming, Apple events, and System 7. In preparing the Tools Advisor, Developer University collected a considerable body of catalog-style information on products available. But a catalog is rarely sufficient. It’s not enough to read lists of capabilities as recorded by manufacturers. You need to know how the tools get used in actual projects. So the Tools Advisor provides a collection of stories by programmers who use the tools it describes. These stories provide a real feel for the product. They’re sometimes critical, warning of potential hazards and shortcomings of particular tools. They’re also often inspiring in explaining how particular achievements were made. To help you find stories most appropriate to you, the Advisor lets you match a loose profile of your needs and wants to stories by developers with similar backgrounds and tasks. To augment its profiles of programming tools, critical essays, and developers’ stories, the Tools Advisor includes a glossary that describes exactly what technical and trade terms mean and what they imply to a development effort. Glossary entries and cross- references let you navigate the intricate terrain of technical information without losing sight of your particular interests. Two versions of the Tools Advisor are available. The disk- based edition includes screen shots and comprehensive data on programming tools in a range of categories as well as technical details on the Macintosh and on Macintosh programming in general. The CD-ROM edition of the Tools Advisor adds demonstration versions of dozens of tools; for instance, you can take a multimedia tool for a test drive as you learn about animations and about other developers’ experiences with that product. We hope that with the Tools Advisor guiding you, you won’t feel lost any more. FEELING LOST? SEE THE MACINTOSH DEVELOPMENT TOOLS ADVISOR
Reading notes: Pull-quote and sidebar text appear interleaved in the extracted copy, so reading order between columns may be unclear.
- Printed product names
- Macintosh Development Tools Advisor · Developer CD Series · HyperCard · CD-ROM · PostScript® · PICT · EPS · System 6.0.5 · System 7 · HyperCard 2.0
- Printed dates
- Winter 1992
- Languages
- English
PDF page 9
Macintosh developers faced with the dilemma of which platform to develop software for—machines with the original QuickDraw or those with Color QuickDraw—can always choose to write code that runs adequately on the lower-end machines and gives additional functionality when running on the higher-end machines. While this sounds like a simple and elegant solution, it generally requires a great deal of development and testing effort. To make this effort easier and the outcome more satisfying, we offer techniques to save color images and process them for display on 1-bit (black-and-white) devices. Suppose you’re writing a program that controls a 24-bit color scanner and you’d like it to work on all Macintosh computers. The problem you’ll run into is that machines with the original QuickDraw (those based on the 68000 microprocessor) only have support for bitmaps, thus severely crippling the potential of your scanner. But don’t despair. In our continuing quest to add Color QuickDraw functionality to machines with original QuickDraw, we’ve worked out techniques to save color images and process them for display, albeit in black and white, on the latter machines. We’ve also come up with a technique to address the problem of a laser printer’s inability to resolve single pixels, which results in distorted image output. This article and the accompanying sample code (on the Developer CD Series disc) share these techniques with you. SAVING COLOR IMAGES The key to saving color images is using pictures. Recall that a picture (or PICT) in QuickDraw is a transcript of calls to routines that draw something—anything. A PICT created on one Macintosh can be displayed on any other Macintosh (provided the version of system software on the machine doing the displaying is the same as or later than the version on the machine that created the picture). For example, on a Macintosh Plus you can draw a PICT containing an 8-bit image that was created on a MAKING THE MOST OF COLOR ON 1-BIT DEVICES Winter 1992 7 KONSTANTIN OTHMER has wanted his photograph to appear in Sports Illustrated for as long as he can remember. Unfortunately, his college was in the NCAA’s Division III, which is often overlooked by SI’s editors, and somehow they’ve missed his virtuosity on the ski slopes at Tahoe, Vail, and Red Lodge. So Kon’s had to scale down his dream, setting his sights on making the pages of develop instead. Here he’s gotten to try on various alter egos. To come up with his latest persona, he spent a few late nights in a secret Apple lab with skilled pixel surgeon Jim Batson.• KONSTANTIN OTHMER AND DANIEL LIPTON MAKING THE MOST OF COLOR ON 1-BIT DEVICES
Reading notes: Byline and sidebar text reading order may be ambiguous Phrase 'setting his sights on making the pages of develop instead' appears to have a missing word
- Printed product names
- Macintosh · QuickDraw · Color QuickDraw · Macintosh Plus · Developer CD Series · Sports Illustrated · Macintosh computers
- Printed dates
- Winter 1992
- Languages
- English
PDF page 10
Macintosh II. With System 7, you can even display PICTs containing 16-bit and 32- bit pixMaps on machines with original QuickDraw. (Of course, they will only be displayed as 1-bit images there.) Creating a picture normally requires three steps: 1. Call OpenPicture to begin picture recording. 2. Perform the drawing commands you want to record. 3. Call ClosePicture to end picture recording. The catch is that the only drawing commands that can be recorded into a picture are those available on the Macintosh on which your application is running. Thus, using this procedure on a machine with original QuickDraw provides no way to save color pixMaps into a picture, since there’s no call to draw a pixMap. In other words, you can’t create an 8-bit PICT on a Macintosh Plus and see it in color on a Macintosh II. But that’s exactly what would make a developer’s life easier—the ability to create a PICT containing deep pixMap information on a machine without Color QuickDraw. With this ability, you could capture a color image in its full glory for someone with a Color QuickDraw machine to see, while still being able to display a 1-bit version on a machine with original QuickDraw. To get around the limitations of the normal procedure, we came up with a routine called CreatePICT2 to manually create a PICT containing color information. Your application can display the picture using DrawPicture. Now, you may be wondering whether creating your own pictures is advisable. After all, Apple frowns on developers who directly modify private data structures, and isn’t that what’s going on here? To ease your mind, see “But Don’t I Need a License to Do This?” The parameters to CreatePICT2 are similar to those for the QuickDraw bottleneck procedure stdBits. The difference is that CreatePICT2 returns a PicHandle and does not use a maskRgn. The first thing the routine does is calculate a worst-case memory scenario and allocate that amount of storage. If the memory isn’t available, the routine aborts, returning a NIL PicHandle. You could easily extend this routine to spool the picture to disk if the memory is not available, but that’s left as an exercise for you. ( Hint : Rather than writing out the data inline as is done here, call a function that saves a specified number of bytes in the picture. Have that routine write the data to disk. Essentially, you need an equivalent to the putPicData bottleneck.) At this point the size of the picture is not known (since there’s no way to know how well the pixMap will compress) so we simply skip the picSize field and put out the picture frame. Next is the picHeader. CreatePICT2 creates version $02FF pictures, with a header that has version $FFFF. This version of the header tells QuickDraw to ignore the header data. (OpenCPicture, available originally in 32-Bit QuickDraw d e v e l o p Winter 1992 DANIEL LIPTON (a.k.a. “The PostScript Kid”) is a two-and-a-half-year veteran of Apple’s System Software Imaging Group, where he’s working on the next generation of printing software for the Macintosh. When he’s not thinking backward, he enjoys taking in a good flick, spending time with his iguana, “Iggy” (who’s never quite forgiven Dan for the time she nearly froze to death in the cargo compartment of a 747), and writing zany new lyrics to classic tunes (his “Working in the Print Shop Blues” is well known to his coworkers). Most of all, Dan enjoys building and flying model airplanes, and he’s recently joined the competition circuit. In fact, when asked what he’d really like to do with his life, Dan replies: sunny { { { { hours 8 { flying } for } rather_be } dayforall } } if • 8
Reading notes: Final line of the author biography ('sunny { { { { hours 8 { flying } for } rather_be } dayforall } } if •') is garbled and of uncertain meaning.
- Printed product names
- Macintosh II · Macintosh Plus · QuickDraw · Color QuickDraw · CreatePICT2 · DrawPicture · OpenPicture · ClosePicture · PICT · stdBits · putPicData · OpenCPicture · Winter 1992
- Printed dates
- Winter 1992
- Languages
- English
PDF page 11
version 1.2 and in Color QuickDraw in System 7, still creates version $02FF pictures, but the header version is now $FFFE and contains picture resolution information.) In addition, the bounds of the clipping region of the current port are put in the picture. Without this, the default clipping region is wide open, and some versions of QuickDraw have trouble drawing pictures with wide-open clipping regions. Next we put out an opcode—either $98 (PackBitsRect) or $9A (DirectBitsRect), depending on whether the pixMap is indexed or direct. Then the pixMap, srcRect, dstRect, and mode are put in the picture using the (are you ready for this?) PutOutPixMapSrcRectDstRectAndMode routine. Finally, either PutOutPackedDirectPixData or PutOutPackedIndexedPixData is called to put out the pixel data. There’s an important difference between indexed and direct pixMaps here. The baseAddr field is skipped when putting out indexed pixMaps and is set to $000000FF for direct pixMaps. This is done because machines without support for direct pixMaps (opcode $9A) read a word from the picture, skip that many bytes, and MAKING THE MOST OF COLOR ON 1-BIT DEVICES Winter 1992 9 The reason Apple doesn’t want developers modifying data structures is that it makes it hard to change them in the future. For example, early Macintosh programs locked handles by manually setting the high bit of the handle rather than calling HLock. This caused numerous compatibility problems when the 32-bit-clean Memory Manager was introduced. So what gives? What if Apple changes OpenPicture so that it creates a totally different data format—won’t the manually created pictures break? Calm down, because the answer is no. The difference between creating your own pictures and directly modifying other data structures is that Apple can’t make the current picture data format obsolete without invalidating users’ data that exists on disk. Just as you can still call DrawPicture on version 1 pictures and everything works, you will always be able to call DrawPicture on existing version 2 pictures, regardless of the format of pictures created in the future. One possible pitfall is that you might create a picture with subtle compatibility risks that draws on the existing system software but breaks at some future date. To minimize the chances of such an occurrence, you should compare the pictures you generate with those that QuickDraw generates in identical circumstances. You must be able to account for any and all differences. Creating your own pixMaps (as our example code does) is definitely in the gray area between risky and outright disastrous behavior, and you shouldn’t do it. Then why would an article written by two upstanding citizens do such a thing? The answer is that the pixMaps used by this code are kept private; they’re never passed as arguments to a trap. We could just as easily have called them something else, but pixMaps work for what we’re doing, so we used them. If you want to pass a pixMap to a trap, you can generate it using the NewPixMap call (not available on machines with original QuickDraw) or let other parts of Color QuickDraw, like OpenCPort, generate it. BUT DON’T I NEED A LICENSE TO DO THIS?
Reading notes: Running page header and footer text ('MAKING THE MOST OF COLOR ON 1-BIT DEVICES Winter 1992', page number '9') interrupts the body text, so reading order across the page break should be checked.
- Printed dates
- 1992 · $02FF · $FFFE · $98 · $9A · $000000FF
- Languages
- English