delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/24/13:17:20

From: quacci AT vera DOT com (jon)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Quick question re: Allegro BITMAPs
Date: Sat, 24 May 1997 13:41:25 GMT
Organization: Yale University
Lines: 30
Message-ID: <3386ead8.2783395@news.cis.yale.edu>
References: <33847D77 AT relay DOT probe DOT co DOT uk>
NNTP-Posting-Host: slip-ppp-node-02.cs.yale.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Thu, 22 May 1997 17:07:00 GMT, "Hargreaves, Shawn"
<shawnh AT probe DOT co DOT uk> wrote:

>
>SpankE writes:
>> So to access a point just use something like this:
>> bmp->line[x_position][y_position];
>
>Almost, but you got the x and y the wrong way round.
>What you really meant was bmp->line[y][x]  :-)
>
> Shawn Hargreaves.

I experimented with it, and I found that:

BITMAP *data1;
unsigned char *temp;
temp=line[0];
temp = data1->line[0];

makes it easy to treat *temp as a linear 1-D array to directly access
a RAM bitmap. For example, in a 320x200 RAM BITMAP, temp goes from
temp[0] to temp[65000], accessed like temp[y*320+x]. If you have a 256
bitmap width, you can really fly through it by temp[(y<<8)+x].

Maybe all this is fighting the point of a BITMAP, but I find that this
sort of array accessing can be a very fast way to access the data for
certain things you want to do.

Thanks, guys.

- Raw text -


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