jmunkki@santra.UUCP (Juri Munkki) (12/07/87)
I experimented with offscreen pixmaps today. It seems that Color Quickdraw is very flexible, but too slow for good animation. Most of the overhead comes from color matching and conversion. I guess I could write my own color matching routine, but I think there should be a fast way to do a simple copy operation. In most painting programs the actual painting could be done on an offscreen bitmap with the same color table as the best gDevice. It takes about twice as much time to do a copybits in srcCopy mode than it takes in the srcXor mode. Below is a short program that draws to an offscreen pixmap and then copies it back to the screen. Try different transfer modes and note the speed difference. The code is written in LS C 2.13. Even srcXor, which is the fastest usable mode, is too slow for really high quality animation. How can it be done faster? #include <MacTypes.h> #include <QuickDraw.h> #include <Color.h> #include <WindowMgr.h> WindowPtr onScreen; CGrafPtr offS; RGBColor temp; PixMapPtr offP; void main() { int i; InitGraf(&thePort); InitCursor(); InitFonts(); InitWindows(); onScreen=GetNewWindow(1000,0L,-1); offS=(CGrafPtr)NewPtr(sizeof(*offS)); OpenCPort(offS); HLock(offS->portPixMap); offP=*(offS->portPixMap); SetRect(&offP->bounds,0,0,256,256); PortSize(256,256); offP->rowBytes=32768L+256; offP->baseAddr=NewPtr(65536L); EraseRect(&offS->portRect); temp.blue=65535; temp.red=0; temp.green=0; RGBForeColor(&temp); for(i=0;i<256;i+=4) { MoveTo(i,0); LineTo(255-i,255); } SysBeep(10); HideCursor(); for(i=100;i;i--) CopyBits(&((GrafPtr)offS)->portBits,&onScreen->portBits, &offS->portRect,&offS->portRect,srcXor,0); SysBeep(10); while(!Button()); } Juri Munkki jmunkki@santra.hut.fi jmunkki@fingate.bitnet lk-jmu@finhut.bitnet P.S. The window is longword aligned and a color table was copied from the system file.