Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Bitmap crash

This thread is locked; no one can reply to it. rss feed Print
Bitmap crash
Matias Persson
Member #15,093
May 2013

Hi, I've been messing with a project for some hours now, and I keep getting this bitmap crash, it can't load the bitmap. I've even tried using full path, which doesn't work either.
Project is attached to the thread, please have a look and tell me what is wrong, cause I can't seem to figure it out.

Also, when compiling in release mode I get this weird error on al_wait_for_event(event_queue, &ev), would love to know what is wrong on that one too.
The error is as followed below
potentially uninitialized local pointer variable 'event_queue' used.

Thanks in advance ;D

RPG Hacker
Member #12,492
January 2011
avatar

potentially uninitialized local pointer variable 'event_queue' used.

Well, the error is quite descriptive, if you ask me. You're using a variable that might not have been initialized by the time you're using it. The easiest way to do this is usually something like this (if it's a pointer type):

event_queue = NULL; // C style

event_queue = nullptr; // C++ style

Or like this (if it's a struct and there is no initialize function for it):

memset(&event, 0, sizeof(event));

Matias Persson
Member #15,093
May 2013

Worked perfectly, now there's still just that annoying bitmap crash.

RPG Hacker
Member #12,492
January 2011
avatar

background = al_load_bitmap("C:/images/background.png");

What exactly are you trying to load there? Images you're loading in your game shouldn't be just random images somewhere on your disk, they should lie in a subfolder of your game folder. Plus, the image you're referencing here isn't even included in game.rar, the only image included is 00001.png, so no really way for us to test this with your exact image.

Wait, nevermind. You already mentioned that you just put in an absolute path to test if that works, so forget what I just said.

As for the crash, don't PNG files require some kind of image addon to be initialized? I think that's missing in your code. I'm not sure what the addon was called, but I think it was literally just "image addon" or something like that.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

RPG Hacker
Member #12,492
January 2011
avatar

He's got al_init_image_addon() in his Initialize function.

Guess I've overlooked that. I saw a bunch of addon initializations, but not this one.

Matias Persson
Member #15,093
May 2013

I have another project on my drive on the same computer, works fine printing png images.

GullRaDriel
Member #3,861
September 2003
avatar

Maybe set the color depth before loading ?
It has helped to do so in the past.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Matias Persson
Member #15,093
May 2013

I'll try.

Edit: Didn't work.

GullRaDriel
Member #3,861
September 2003
avatar

Maybe try what they said. Sometimes editors save weird formats.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Matias Persson
Member #15,093
May 2013

I did all of the things described several times using both different editors and files.

Wetimer
Member #1,622
November 2001

You should setup a debugger and step into al_load_bitmap function to find out what happens.

<code>if(Windows.State = Crash) Computer.halt();</code>

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Matias Persson
Member #15,093
May 2013

I've tried other formats than png.
I got my binaries from https://www.allegro.cc/files/
version 5.0.10, it has bitmap support, as I said, I have another project working just fine.
Here, I'll even attach it to this post.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Allegro 5.0.10 is very old. You should update to 5.2.X. What compiler are you using?

If you're interested :

I offer a binary distribution of MinGW available here :
https://sourceforge.net/projects/unofficialmingw/files/?source=navbar

and Allegro 5.2 here :
https://sourceforge.net/projects/unofficialallegro5distribution/files/?source=navbar

For right now, I recommend MinGW 4.8.1-4 and the A52GITdistro2 built with it because Allegro 5.2.1.1 has some unresolved issues with timers.

https://sourceforge.net/projects/unofficialmingw/files/mingw_4_8_1-4.tar.7z/download
https://sourceforge.net/projects/unofficialallegro5distribution/files/A52GITdistro2.tar.7z/download

I downloaded your projekt, and successfully loaded and displayed your png files that you included with it using Allegro 5.2.0. You should update your allegro version, as there must have been some png loading bugs fixed between 5.0.10 and 5.2.0.

Matias Persson
Member #15,093
May 2013

The last attached project works fine for me too, the one that I attached first is the one that doesn't work.
But yeah, I guess 5.2 has a lot of fixes that 5.0.10 lacks, but I use Visual Studio 2013, and I don't know how to set up allegro on mingw xD

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I successfully loaded and displayed your "Mujaffa Spillet" image 00001.png using Allegro 5.2.0.

Can you update to MSVC 2015? Then you can use Nuget to install allegro 5.2.

Otherwise you'll have to compile allegro yourself, and that's kind of a nightmare with MSVC. SiegeLord has some build scripts set up to do it for you. You can find them here :
https://www.allegro.cc/forums/thread/616170/1022755#target

Matias Persson
Member #15,093
May 2013

Perhaps it is time to finally switch IDE?
Any recommendations?
I know of Codeblocks and have used it before, but I don't know how to setup Allegro for it :/

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: