Mail Archives: djgpp/1997/05/24/13:17:20
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 -