Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!gatech!ncar!elroy.jpl.nasa.gov!sdd.hp.com!spool2.mu.edu!uunet!cbmvax!ken From: ken@cbmvax.commodore.com (Ken Farinsky - CATS) Newsgroups: comp.sys.amiga.programmer Subject: Re: Drawing images in intuition. HELP! Message-ID: <17965@cbmvax.commodore.com> Date: 23 Jan 91 17:12:11 GMT References: <10330@pasteur.Berkeley.EDU> Reply-To: ken@cbmvax.commodore.com (Ken Farinsky - CATS) Distribution: usa Organization: Commodore, West Chester, PA Lines: 53 In article <10330@pasteur.Berkeley.EDU> morgan@cory.Berkeley.EDU (Alan Morgan) writes: > >USHORT imagepts[]={ /* stuff */ }; >struct Image picture = { 0,0,16,16,3,imagepts,1,0,NULL}; > >main() >{ >struct Window *NoBorder; > >OpenAll(); /* Opens up intuition for me */ >NoBorder = (struct Window *)makeWindow( /* window parameters */ ); >DrawImage(NoBorder->RPort,&picture,10,10); >for(i=0;i<500000;i++); >CloseWindow(NoBorder); >} Sorry about hacking your program to death, here are some comments: Your image data must be in chip memory. You can do this with AllocMem() then copy the data to the new space. Don't forget to FreeMem the memory when you are done. And to check for successful allocation. You have planepick for the image set to 1, and planeonoff set to 0. You probably want planepick to be 7 (binary 0111) to tell the system to put data in the lower 3 bitplanes. PlaneOnOff of 0 is fine, this tells the system not to change any of the unused bitplanes. You have only supplied 1 bitplane worth of data, but the code specifies 3 bitplanes. (You define the image as 16 wide, 16 high and 3 deep.) Don't busy wait, not even in example code! You can replace the "for(i=0;i<500000;i++);" with something like "Delay(100);" Don't forget to close Intuition. You opened it in OpenAll(), but then never close it. You open intuition and a window without checking for success. If these fail, your program will blow up. Error check with code like: if (NULL == (win = OpenWindow(...))) { /* error reporting/handling code goes here */ } else { /* do stuff */ CloseWindow(win); } -- -- Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines uucp: ken@cbmvax.commodore.com or ...{uunet,rutgers}!cbmvax!ken bix: kfarinsky