Hey guys, I'm new with the allegro community and I know C programming.

I've recently started doing allegro Code::blocks development, and that's been a real drag lately. I cant seem to load a bitmap image (mario8.bmp), and yes I'am totally aware of the allegro 5 library, but I prefer to use allegro 4 for now, and its much easier. Here down below I will provide the code that I used from a tutorial ( https://www.youtube.com/watch?v=ceOTjZOD6wo&t=1s ) I'm running on a 32 bit machine with windows vista, it appears in this tutorial he uses something older. Anyway, I'm not sure what's going on, and just to answer any sample questions, yes the image is named correctly, the file is in the folder, the image is where the .exe file is. Every time I run the program it goes to the 8-bit color scheme on windows vista then crashes and says "Allegro Game.exe has stopped working", then returns to its normal color scheme. Please help me, I don't know how to solve this or what to do.

Yes, for each C::B project, if you're running it from within the IDE you need to have all your files (images, dlls, etc) in the project's base directory. When the project is finished and you want to share it, then everything needs to be with the .exe.

You don't need to be in 8-bit mode to load 8-bit images. Allegro will automatically convert them to the bit depth you're using when it loads the image.

edit:

When you say create your own bitmaps, do you mean you want to load ones you've created in a paint program, or ones you've created in your code?

Just a note, newer versions of Windows don't do 8bit well anymore, they tend to mess up the palette, so I strongly recommend moving up to 24 or 32bit (32bit is just 24 with an alpha channel). You can still use the pink colour for transparent sections in Allegro 4 at these depths.

My Deluxe Pacman 1 (link in my sig) uses Allegro 4 and used to be 8 bit many moons ago. Switching it to use 32bit with Allegro 4 was easy and ensures it looks proper on all systems.

My Deluxe Pacman 2 uses Allegro 5. If you take the time to learn to use Allegro 5 it is well worth switching to.

+Neil Roy so good to see you sir, I didn't know you use allegro, I remember seeing you on VertoStudio's video in the comment section advising him a lot, thanks for the recommendation and I just recently moved on from SDL 2, I like allegro 4 better than allegro 5, I find that they completely changed the whole API and I wasn't happy at all with that, plus its way easier for me to get my way around. I'm not just focusing on the performance of it, I'm also looking out for the rate/ difficulty of it I must say it is way easier than SDL and in allegro, you could write int main() with out any argument counters with in the parentheses of it. Its just the way I learnt it with the simple int main(). No doubt about it I will probably use allegro 5 for my CPP projects but as I am doing C right now, I thinks its best to play it allegro 4 safe and plus if I couldn't even load a bitmap image in allegro 4 (now fixed) then how could I load an bitmap image in allegro 5.

Anyway, I'm just saying, after all I know C and its rather fun to write apps in it, and I am aware of course that C can do allegro 5, but I still prefer allegro 4 just because of its simplicity. Thanks again though

Also, I'm having problems with my bitmap, what did you do for the other bitmap to go well with allegro I tried using another mario image, what did you do for the other one, and why isn't this one showing up?

gah, please don't litter your project directory with data files. Put them in their own folder under a single folder where your executable resides. C::B has a setting to change the working directory when you use C::B to run it. Go to Menu->Project->Properties. Go to the Build targets tab and change the execution working directory and output filename. Done. Voila.

As for your bitmap, it's corrupt, or A4 doesn't recognize its particular format.

Try this mario8a.bmp with exbitmap.exe. Run the Run443Examples.bat file in the allegro folder and then run "exbitmap.exe mario8a.bmp" after saving mario8a to the bin/examples folder. All I did was load it in paint.net and then save it again as a different 8 bit bitmap. Whatever paint program was used to create and save mario8.bmp apparently didn't save it in a format allegro 4 can load.

+Edgar Reynaldo I don't have the run thing, I installed allegro using this tutorial: https://www.youtube.com/watch?v=QPaiGhrGq6I and it showed me how to configure allegro for code::blocks in my MinGW folder for code::blocks it doesn't have the run thing that you suggest I use I didn't install it the way you last told me to do it.

+LennyLen how did you load the 8-bit mario image without it crashing mine seems to crash every time I load it and I set it to the desktop color in the allegro code, i don't get it. It should support my windows because I set it to my desktop color. Please help!! D:

So load_bitmap in allegro 4 wont work and every time I try and load an image it crashes, I have my bitmap images in the same folder next to my code block files and I'm trying to load the 8-bit Mario, I provided an image of my folder as well as the code::blocks IDE in the Attachment.

I don't know why its not loading or what it means for it to be corrupted.

I don't get what's wrong with it I get 0 errors and 0 Warnings in code.When I seem to load mario 8 its fine, I don't know if its the color or anything, whereas if mario 32 was loaded (which has no difference what so ever its just an 8-bit mario with no change in color scheme what so ever) it fails and I get "Allegro Game has stopped working", and the console returns a negative value, and other stuff...

I just don't know what to do now, I've provided images and stuff to help and make it easier. The main problem is when ever I load the image, it NEVER shows up.. well, only if its mario8.bmp which is just a purple square which Lenny gave me instead, because he said to try it.

QUESTION: How would you create your own bitmap images for allegro

Thanks again coderthatcancode

EDIT: It worked it turns out you need to edit the mario32.bmp in a paint program and then save it as an 24-bit bitmap, unblock the file as it may be blocked in properties

You're not checking any return values. load_bitmap can, and sometimes does, fail. Your original mario8.bmp file was in a format that Allegro 4 cannot understand. That's why it fails, and load_bitmap would have returned a null pointer in that case. That's why Lenny's and my mario8a.bmp both display properly. Or else it is because your image file is not in the directory it is supposed to be in, or your current working directory is not the one with the image in it.

It worked it turns out you need to edit the mario32.bmp in a paint program and then save it as an 24-bit bitmap, unblock the file as it may be blocked in properties

Although when I edited in paint it came out really weird when I saved it as 24-bit image, which is what allegro understands. Do you think if I used a different paint program it would save differently if I saved it as 24 bit?

Allegro 4 CANNOT LOAD certain types of BMP files. More accurately, a BMP file with a specific VERSION header. Merely loading the same bitmap in GIMP and resaving it as BMP can fix it.

If you have a choice for file formats, always use PNG. It's basically a compressed BMP. (Lossless. So it looks the same.) Nobody uses BMP anymore. There's basically zero advantage to using BMP, and PNG is supported in Allegro 4.

I ran into the exact same problem when I trying to use Allegro 4 for an image manipulation tool. It kept blowing up on bitmap files and I found it out the hard way the header issue.

-----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs

Nah, I still prefer allegro 4, its way easier than allegro 5 and for me it makes a lot more sense.

I will probably move on to allegro 5 when I learn C++, but I will take note of it, its still possible to develop a game in allegro 4 anyway.

Yes, I am aware of .png files I've used them a lot when it came to SDL2, which is why I moved on to allegro 4. Its way easier than SDL2 in my opinion and that's what I like about it, it also seems that there a lot of people on the allegro web site, so if I launch a new game people might know about it, plus allegro 5 in a way is kinda advanced, I've programmed in it before and I didn't like it because it just changed the allegro that we know. Why would I want that? I will most likely use if for C++ for sure, and I know it works for C as well, but if you ask me I think C++ would work better, Thanks anyway.

I would have to disagree with this. Allegro 4 is good at what it does, which is software rendering. However if you want hardware acceleration, or an event based system that doesn't poll, then yes, A4 sucks compared to Allegro 5.

My game Skyline uses Allegro 4 and a custom function I wrote to draw gradient circles. It's quite fast. I had SiegeLord's knowledge and expertise to help me write it though. However, the modern way to do it would be to use a shader on the gpu. I don't have that knowledge yet, so for me and Skyline A4 is still a good choice. It has it's niches, but yes in the overall picture A4 is obsolete and should be replaced by A5 whenever possible.

It worked it turns out you need to edit the mario32.bmp in a paint program and then save it as an 24-bit bitmap

So basically, what you were telling him all along. And if he'd used the full version of the code I posted, it would have told him that the problem wasn't finding the file, but that the problem was loading it.