Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!stanford.edu!msi.umn.edu!umeecs!zip!spencer From: spencer@eecs.umich.edu (Spencer W. Thomas) Newsgroups: comp.sys.mac.programmer Subject: Re: Creating an offscreen pixmap Message-ID: Date: 25 Mar 91 06:46:04 GMT References: Sender: news@zip.eecs.umich.edu Organization: University of Michigan EECS Dept Lines: 40 In-Reply-To: kwel1@cs.aukunic.ac.nz's message of 17 Mar 91 23:19:49 GMT Here's a hunk of Think C code that does it. You need the 32-bit QD header file & glue, of course (I've got that for Think C, if you've got something else, you're on your own.) static GWorldPtr the_world = 0L; ... GWorldPtr old_world; GDHandle old_dev; ... MoveTo( 20, 20 ); DrawString( "\pPlease wait, creating bitmap..." ); SetRect( &max_rect, 0, 0, 255, 127 ); if ( NewGWorld( &the_world, 32, &max_rect, 0L, 0L, 0 ) != noErr ) { MoveTo( 20, 40 ); DrawString( "\pNewGWorld failed, sorry."); return; } /* Remember the current world. */ GetGWorld( &old_world, &old_dev ); SetGWorld( the_world, 0L ); LockPixels( the_world->portPixMap ); ... draw into the pixmap ... UnlockPixels( the_world->portPixMap ); SetGWorld( old_world, old_dev ); DrawString("\p done."); ... and to copy it to the screen: GetPort( &curr_port ); LockPixels( the_world->portPixMap ); CopyBits( &the_world->portPixMap, &curr_port->portPixMap, &src_rect, &max_rect, srcCopy, 0L ); UnlockPixels( the_world->portPixMap ); -- =Spencer W. Thomas EECS Dept, U of Michigan, Ann Arbor, MI 48109 spencer@eecs.umich.edu 313-936-2616 (8-6 E[SD]T M-F)