sdh@joevax.UUCP (Steve Hawley) (06/12/86)
Ok, folks this is what I'm trying to do:
I want to use bitmaps for drawing images, but I loathe to define them
as Aztec C does by having a huge amount of "StuffHex" calls and lots
of ugly hex which is a pain to alter.
What I thought would be peachy keen is to draw whatever I wanted in
MacPaint, cut it to the clipboard and paste it into my file as a resource
of type PICT. This works fine. I can read in pictures and splay them out
to the screen. The problem is, I don't want to use the type picture. I
would like to draw the picture into my bitmap definitions and then draw
the bitmap on the screen instead. This should be inherently faster than
using the DrawPicture routine, as no unpacking etc needs to be done. The
problem is that I can't draw pictures into the bitmaps properly. I use
the call SetPortBits to make my bitmap the current one for drawing, but
this has no effect. What follows is the code I'm using. What's the story?
Is there an easy way to accomplish what I'm trying to do?
(PS the MANX people were eager to help, but were unfamiliar with what I
was trying to do.)
#include <quickdraw.h>
#include <window.h>
#include <event.h>
#include <toolutil.h>
WindowRecord wRecord;
WindowPtr myWindow;
EventRecord myEvent;
main ()
{
Rect screen, trect;
PicHandle picture;
BitMap bm;
QDPtr area[24];
InitGraf(&thePort); /* do inits */
InitWindows();
FlushEvents(everyEvent,0);
SetCursor(&arrow);
HideCursor();
picture = GetPicture(255);
SetRect(&screen, 20, 60, 220, 240); /*set up window */
myWindow = NewWindow(&wRecord, &screen, ctop("BitMap"),1,0,(char*)-1,1,(long)0);
SetPort(myWindow);
ShowWindow(myWindow);
bm.baseAddr = area;
bm.rowBytes = 4;
SetRect(&(bm.bounds), 60, 60, 85, 84);
SetPortBits(&bm);
PenMode(patOr);
/* DrawPicture(picture, &(bm.bounds));
KillPicture(picture); */
SetRect(&trect, 50, 50, 75, 74);
SetPortBits(&(myWindow->portBits));
CopyBits(&bm, &(myWindow->portBits), &(bm.bounds), &trect, srcXor, 0L);
while(!Button());
}
I enclosed the stuff that don't go in comments.
Steve Hawley
joevax!sdh