Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Bitmaps Display Problem

Credits go to Edgar Reynaldo for helping out!
This thread is locked; no one can reply to it. rss feed Print
Bitmaps Display Problem
nico_c++
Member #16,940
January 2019

I have a little problem:

I am trying to load a lot of Bitmaps, which are making a map.
You can see that in the screenshot.
It's all working very fine, except the fact, that when there are overlaps, there is an orange box and I don't know how to get rid of that.

Does someone know, what this boxes are and why they are there and how I get them away?

The tile-bitmaps are all transparent, also the bitmaps from the units (that means, there is no white background or something like that, it is a transparent background).

Please help me, if you know something to do there.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

First off, are you using Allegro 4 or 5? And please note the sub-versions as well.

Second, can you post the two (or more) sprites used in that screenshot as an attachment? I doubt there's anything wrong with the images though.

It sounds like a blending mode problem. Have you changed it at all?

It could be a loading problem as well, as bitmaps are converted to the current format upon loading. If they're png, this shouldn't matter, as they are 32bit RGBA to begin with.

Third, post code in <code>code goes here</code> tags. Post the display code and the loading and setup code. Then maybe we can pinpoint what is wrong.

Honestly, I've never seen anything like that happen before.

nico_c++
Member #16,940
January 2019

Sorry, I am not on the PC right now.
But I can tell you how I had done this.
First of all I use Allegro 5 in Visual Studio 2017,if thats for help.
Than I have a class "Map" which has a vector of tiles.
And for all the tiles I do
Image = al_load_image("path");
al_draw_image(Image, x, y, 0);
al_destroy_image(Image);

And x and y are
For all Tile[i].y % 2 == 0
(Tile[i].x * 100) - 50
(Tile[i].y * 75) - 75

And for all i.y % 2 * != 0
(Tile[i].x * 100) - 100
(Tile[i].y * 75) - 75

At least I think so, thats because of the form of the tiles, u can see that in the screenshot.
The 100 and 75 and so on are just how long the bitmaps are.

But that's all not my point, when the bitmaps are "overlap", there are these orange boxes, u can see that in the screenshot.

And the tiles are overlapping because I drawed them a bit longer than the 75 and 50 pixel rims and so on.
But why are there then these orange boxes??

I hope you understand a bit what I wrote, I will upload the tile and the unit bmp later, also so code.
But maybe you know a answer now.

Thanks for now

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Allegro 5 is still too vague to be helpful. But your using binaries for MSVC so they could be at least a few years old by now. Unless, actually, you're using Nuget, right? That means version 5.2.4 . Which is the latest stable release.

Your loops look okay. Each column overlaps the next by half its width.

Hold on I'll be right back.

Gotta get off my phone and go inside to my computer.

Honestly, I don't know why they're orange 🍊.

BRB

nico_c++
Member #16,940
January 2019

Yes I use Nuget.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Okay that solves that.

One thing I saw in your code is :

Image = al_load_image("path");
al_draw_image(Image, x, y, 0);
al_destroy_image(Image);

I hope you don't do all three of those things in the same loop. That would be a terrible waste of resources and cpu and disk access reloading your images on every frame. It's not a memory leak at least.

Really I can't tell anything else without seeing code and the particular images that are overlapping in orange.

Just make a zip file of your source and your resources and I'll build it myself. Include the solution for MSVC 2017. I have it installed and I can test your code myself. ;)

nico_c++
Member #16,940
January 2019

Okay,
I make you a zip file in 2 or 3 hours.
What do you mean by the solutions?
Well I know what you mean, but I think when you install the allegro library with Nuget, it will set up the Linker and Compiler automaticlly.

Edit:

Just solved the problem myself.
I don't use bitmaps, I use pngs.
Easy peasy.
Bitmaps have problems with transparency, which they can't save in any information!
So a "transparent" pixel in a picture hasn't the Info '0', in png it has!
But thank you anyway!!!! 8-)8-)8-)

Go to: