morten@cs.qmw.ac.uk (Morten Ronseth) (08/03/90)
In an attempt to implement all the 16 normal blt modes on
the mac, I wrote the little stump of code you see below.
Now, some of the modes requires an off-screen bitmap,
which will, after some blt's be copied to the destination. Now,
the Mac CopyBits is fast enough when I do screen -> screen blt's,
or off-screen -> offscreen. But, when I do a blit FROM screen TO
off-screen, CopyBits takes as much as 2 - 3 secs to complete
the transfer. Surely, this can be remedied. Can someone please point
out to me what I am doing wrong (I must do something wrong, this is
apalling)?
------beginning of code-------------
static WindowPtr myWindow;
static Rect myBounds = { 40, 40, 400, 400 };
BitMap *tmp;
main()
{
MaxApplZone();
InitGraf(&thePort);
InitFonts();
InitWindows();
InitCursor();
myWindow =
NewWindow(0L, &myBounds, "\pBitBLT", true, noGrowDocProc, -1L,
true, 0);
SetPort(myWindow);
/* set up window info */
tmp = (BitMap *)NewPtr (sizeof (BitMap));
(*tmp).rowBytes = (*myWindow).portBits.rowBytes;
(*tmp).bounds = (*myWindow).portBits.bounds;
(*tmp).baseAddr =
(QDPtr)NewPtr ((*tmp).rowBytes * (long) ((*tmp).bounds.bottom -
(*tmp).bounds.top));
if (MemErr) ExitToShell ();
HideCursor();
doBlt (&(*myWindow).portBits, &(*myWindow).portBits, 2);
ShowCursor();
while (!Button());
}
doBlt (src, dst, rule)
BitMap *src, *dst;
int rule;
{
switch (rule) {
/* a & ~b */
case 2: CopyBits (dst, tmp, &(*dst).bounds, &(*tmp).bounds, notSrcCopy, 0L);
CopyBits (src, tmp, &(*src).bounds, &(*tmp).bounds, notSrcBic,
0L);
CopyBits (tmp, dst, &(*tmp).bounds, &(*dst).bounds, srcCopy,
0L);
break;
}
}
-------------end of code-------------
Thanks,
Morten
--
====================================================================
Morten Lerskau Ronseth UUCP: morten@qmw-cs.uucp
Dept. of Computer Science JANET: morten@uk.ac.qmw.cs
Queen Mary and Westfield College ARPA: morten%qmw.cs@ucl-cs.arpa
Mile End Road Easylink: 19019285
London E1 4NS Tlf: 071 975 5220
England. Dept. fax: 081 980 6533