From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: A cool thing... Date: Mon, 20 Apr 1998 18:52:28 +0100 Organization: None Message-ID: References: <353B895B DOT BEDEE7A5 AT sprynet DOT com> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 29 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Ishpeck writes: >BITMAP *getimage(BITMAP *bmp2lookat, int x, int y, int w, int h) { > BITMAP *returnme; > int loopx, loopy; > for(loopy=0;loopy<=h;loopy++) > for(loopx=0;loopx<=w;loopx++) > putpixel(returnme, loopx, loopy, getpixel(bmp2lookat, loopx+x, >loopy+y)); > return returnme; >} /* End getimage function */ Does this function actually work for you? If so you are incredibly lucky, because there is no good reason why it should :-) You are drawing pixels into the returnme image, but this is never initialised anywhere, so it is pointing at a random memory location. Also, your loops go one pixel too far along both axis: to copy exactly the specified width and height number of pixels, the comparison should be a less than, not less than or equal to. But why do you need to do this at all, when Allegro already provides just such a function? You can simply call blit() to do this copy, which will be many times faster than repeated calls to getpixel() and putpixel(). -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa