Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Bitmap Structures?

This topic is 6907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I think I figured out how to do it (please correct me if there is a better way). I have allocated memory and loaded all the bitmap image data into a large array...

UCHAR *bitmapData; // the actual bitmap image data

Then I declared a array of pointers...

UCHAR **bitmap; // array of pointers to the start of each line in bitmapData

Now I am at the point where all I need to do is set the values in bitmap to the starting address of each line in bitmapData. My solution was to use the following code but it causes my computer to crash :-( ...

bitmap[currentLine]=&(bitmapData[currentLine * bitmapInfoHeader.biWidth]);

Would someone please show me the correct way to code the above or explain a better way.

In case the thought has occured to anyone why I am trying to doing this. It is because I would like to be able to plot to a bitmap using this format...

bitmapImage[y][x] = color;

and also to copy from one bitmap to another even if their dimensions are not identical like this

bitmapImage1[y][x] = bitmapImage2[y][x];

Thanx for any info, *POW*

[This message has been edited by POW (edited December 23, 1999).]

Share this post

Link to post
Share on other sites
You have to remember to allocate the lines array. Something like this...

bitmap.line = (unsigned char*) malloc(bitmapInfoHeader.biHeight);

for (y=0; y{
bitmap.line[y] = &(bitmapData[y*bitmapInfoHeader.biWidth]);

... otherwise you'll get GPFs

Share this post

Link to post
Share on other sites
I would like to create a bitmap structure like that in Allegro...

typedef struct BITMAP
int w, h;
int clip;
int cl, cr, ct, cb;
int seg;
unsigned char *line[];

...where *line[] is a table of pointers to the start of each line in the image.
What I would like to know is how I would go about allocating and pointing the *line[] pointer table to an image of any size at runtime.

Thanx, *POW*

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!