Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » hacking the BITMAP structure

This thread is locked; no one can reply to it. rss feed Print
hacking the BITMAP structure
roger levy
Member #2,513
July 2002

before i begin: 1) i don't care about portability. 2) i don't care about compatibility.
with that out of the way, my problem. i need to hold bitmap data in specific areas of memory. basically i want to control where my bitmap data is held. to skip the need to create BITMAP structures i chose to use a pre-created BITMAP and hack it on-the-fly whenever i wanted to do a bitmap operation, by setting the width, height, and *dat pointer. it doesn't seem to work. how can i do this successfully? please let it not be the line pointers! (i was once told that line pointers don't matter in memory bitmaps...)

Thomas Fjellstrom
Member #476
June 2000
avatar

the dat area needs to be that memory.. and the line pointers should be set accordingly. line[0] == dat, line[1] == dat+line_width*1, etc.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Kitty Cat
Member #2,815
October 2002
avatar

Actually, it's:

bmp = create_bitmap_ex(bmp_bpp, bmp_w, bmp_h);
free(bmp->dat);
bmp->dat = my_bitmap_data;
for(i = 0; i < bmp->h;++i)
   bmp->line<i> = bmp->dat + bmp->w*(bmp_bpp+7)/8*i;

If the bitmap structure has a pitch variable, you could use this:
bmp->line<i> = bmp->dat + bmp->pitch*i;</code>

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Korval
Member #1,538
September 2001
avatar

Quote:

Actually, it's

The debug builds of many compilers garbage free-ed memory to catch errors like this.

roger levy
Member #2,513
July 2002

what is the pitch variable and why would some bitmaps have it and not others?

spellcaster
Member #1,493
September 2001
avatar

It's due to memory alignment.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Go to: