[comp.sys.mac] saving a picture

heberlei@iris.ucdavis.edu (Louis Todd Heberlein) (12/07/88)

I am looking for some information on picture formats.  How can I save
a picture that I have created with my own software such that I can
load it up on MacPaint?

I am using Aztec C to draw some 3-D pictures, and I would like to
enhance them with a paint program.  I would prefer not to have to save
every MoveTo and LineTo command, but I am flexible.

Any ideas??

Todd Heberlein

heberlei@iris.ucdavis.edu  (128.120.57.20)

jackiw@cs.swarthmore.edu (Nick Jackiw) (12/08/88)

In article <3361@ucdavis.ucdavis.edu> heberlei@iris.ucdavis.edu (Louis Todd Heberlein) writes:
> 
> I am looking for some information on picture formats.  How can I save
> a picture that I have created with my own software such that I can
> load it up on MacPaint?
> 
> Any ideas??
> 
> Todd Heberlein
> 
A "PNTG" file's format is discussed in TechNote#86: MacPaint Document Format.
It consists of no resources, and a data fork containing a 512-byte header
(which you may fill with zeros) and the compressed 8.5x11 page of data. 
More specifically, this compressed data is the concatenated results of
calling PackBits on each row of a 576x720 tall bitmap. So to write a 
create the data for a paint file:

   BufPos:=BufStart;   {Allocate at least 53072 bytes at BufStart}
   for i:=0 to 511 do BufStart+i:=0; {Clear 512 byte header}
   BufPos:=BufPos+512; {Skip the header}
   srcPtr:=myBitMap.baseAddr; {Get a ptr to the bit-image of the file}
   for i:=1 to 720 do PackBits(srcPtr, BufPos, 72);
                              {PackBits will increment srcPtr+BufPos for
                              you; 72 is the rowBytes of a 560x720 bitmap.}
   WriteHowISeeFit(startingAt:BufStart,byteCount:BufPos-BufStart);

The difficult part about doing this in YOUR application, however, seems to
be that you don't have a BitMap to begin with..just a bunch of LineTo's
drawing in a window.  While you could copy the window into a preblanked
offscreen bitmap of the appropriate dimension, it's probably easier to
store your data as a Quickdraw Picture. Hopefully, you'll be able to
do this just by bracketing all of your graphic calls with a OpenPicture
and a ClosePicture.

Once you've got a picHandle in memory, you can put it on the clipboard with

if ZeroScrap=noErr then PutScrap(GetHandleSize(Handle(myPicHandle)),
                                 'PICT', 
                                Ptr(myPicHandle^));

Now quit your program, and launch any program capable of pasting PICTs from
the clipboard.  This includes MacPaint, for bitmapping it, but also most of
the Draw programs, which might allow you a bit more flexibility than the
initial PNTG file you requested.

Hope this helps.




-- 
+-------------------++-UUCP: ...!rutgers!bpa!swatsun!jackiw-----------------+
| NICHOLAS JACKIW   || Internet: jackiw@cs.swarthmore.edu                   |
|("Jacques-Yves"2U!)|| Bitnet jackiw%campus.swarthmore.edu@swarthmr.bitnet  |
+-------------------++-VGP/MathDept/Swarthmore College, Swarthmore PA 19081-+