Bitmap Structures?

Started by
1 comment, last by POW 24 years, 3 months ago
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).]

Advertisement
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[];
} BITMAP;

...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*

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

This topic is closed to new replies.

Advertisement