- Online Community Forums » Programming Questions » How to load a bitmap????

This thread is locked; no one can reply to it. rss feed Print
How to load a bitmap????
Member #7,281
May 2006

Hello guys,

I'm a newbie in using allegro.

I have created a bitmap that contains frames of a character in 4 gray color set with a tool I wrote myself in .NET. The tool can encode 8x8, 16x16 or 32x32 sprites.

The bitmap that contains the frames is a 24bppRGB format and the size is 16x16. The .NET function loos like this:

private void ExportToWindows(string fileName)
  int width = _ilTiles.Images[0].Width;
  int height = _ilTiles.Images[0].Height;
  Bitmap bmp = new Bitmap(_ilTiles.Images.Count * width, height, PixelFormat.Format24bppRgb);
  Graphics g = Graphics.FromImage(bmp);

  for (int i=0; i < _ilTiles.Images.Count; i++)
    Rectangle rect = new Rectangle(i * width, 0, width, height);
    g.DrawImage(_ilTiles.Images<i>, rect);

So, for loading the bitmap with allegro, I have used the set_color_depth() function with 24 as mode before calling the load_bitmap function.

The problem I have is that I ALWAYS get a NULL pointer when I try to load the bitmap file, thus, no matter the format I use to encode the bitmap.

Can anybody help me please and tell me how to load correctly the bmp please???

Best regards.


Member #2,030
March 2002

Double-check that the bitmap is in the right directory. Then show us your Allegro code.

Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Member #3,025
December 2002

is is a STANDARD bmp ?
re-save it using MS-Paint... you'd be amazed at how many apps create non-standard BMP files.

The more you talk, the more AJ is right. - ML

Member #7,281
May 2006

Actually, the format of the bitmap was incorrect.
I had to forced the format when saving:

bmp.Save(fileName, ImageFormat.Bmp);

and it works fine this way.

Thanks :)


Go to: