Article View: net.micro.mac
Article #6036BitMap problems (help)
From: Steve Hawley
Date: Thu, 12 Jun 1986 14:53
Date: Thu, 12 Jun 1986 14:53
63 lines
2702 bytes
2702 bytes
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
Technical Details
Message-ID:
<172@joevax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!magic!joevax!sdhShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site joevax.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!magic!joevax!sdh From: sdh@joevax.UUCP (Steve Hawley) Newsgroups: net.micro.mac Subject: BitMap problems (help) Message-ID: <172@joevax.UUCP> Date: Thu, 12-Jun-86 10:53:04 EDT Article-I.D.: joevax.172 Posted: Thu Jun 12 10:53:04 1986 Date-Received: Sun, 15-Jun-86 07:16:25 EDT Distribution: net Organization: Bell Communications Research Inc., Morristown, NJ Lines: 63