delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/20/14:32:01

Message-ID: <353B9E65.EC6FF59C@sprynet.com>
Date: Mon, 20 Apr 1998 12:13:41 -0700
From: Ishpeck <aTedjamulia AT sprynet DOT com>
Organization: Lunaticnologies
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: A cool thing...
References: <353B895B DOT BEDEE7A5 AT sprynet DOT com> <rVbdvaAct4O1Ew4m AT talula DOT demon DOT co DOT uk>
NNTP-Posting-Host: 192.41.92.77
Lines: 38
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I get it now!  DUH! 

You can call me stupid if you want.... because, it'd probably be
very applicable. :)

Thanks, Shawn... I needed that.


Shawn Hargreaves wrote:
> 
> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019