How to load a bmp without background - c++

So, I was trying to make game in allegro but I'm currently stuck with this damn blank background which is making me very mad, as I know PNG images have transparency in the background already, but I can't load pngs, i have already download devpaks, installed libraries and stilll nothing good happened, if the best option for me is to use PNG so please tell me how to load then and use then correctly.
If the best option is still to use BMP and there is a algorithm, function or a little code which will make the blank background go away please tell me.
For those who didn't understand what I want there is a better explanation:
http://3.bp.blogspot.com/-r9BaUuMLirc/ThjzRHOMBKI/AAAAAAAAAJI/kUilPnIPJLg/s400/bola_azul.png
its currently in .png, but I transformed to .bmp in paint, so it makes me a blank background and in allegro it shows the whole picture, i want to have only the ball.

As you've commented, with Allegro 4, the color 0xFF00FF is treated as transparent when used with masked_blit() or draw_sprite().
To load PNGs in Allegro 4, you'll want to use loadpng with libpng. You can use the 8-bit alpha channel by enabling the alpha blender with set_alpha_blender().
If you're just starting out, you should be using Allegro 5, which has a modern API and native support for PNG files.

Related

Is there any way to load a .png from my resources without using GDI+?

I am trying to load a .png I stored in my projects resources, in order to set it in a picture control, but I can't quite figure out why. I did some research, and it seems like .png is not really supported with the usual LoadImage()-call.
However, I don't really want to convert it to a bitmap if I can get around it.
So far, I only found resources on how to do it with GDI+, or really ancient win32-api code.
Is there any way to load .png files natively by todays standard?
The "new" way to do it would be Direct2D and WIC, which is demonstrated in the Windows Imaging Component and Direct2D Image Viewer Win32 Sample.
But if the rest of your application is basic controls, Direct2D is overkill. The image has to be converted to a bitmap at some point to be displayed – whether in your GPU or in memory – and GDI+ fits this use case.
If these resources are icons or some other small-ish file (<2mp), I would reccomend embedding the resource as a bitmap. You can keep your asset pipeline as PNG, just add a pre-build step to convert your PNGs to pre-multiplied BGRA bitmaps and use LoadResource. There are pre-built tools to meet this need.

Loading PNG file. Need to get RGBA HBITMAP

I'm trying to create a splash screen that will show transparent png background. So at first I need to load png file into format that is acceptable for the UpdateLayeredWindow calls (basically HBITMAP with RGBA format).
At the moment, I've found Windows Imaging Component, but that does not work for VS2005 (which is mandatory requirement). Using some additional libraries is also a problem.
I've heard that GDI+ can do the trick, but I can't find a proper example unfortunately :( Can anyone help?

SFML 1.6 - Blured text [duplicate]

I'm using SFML 1.6 to make a small game, and I need to display some text, so I use the sf::String class. The problem is, when I increase the size to 96pt, the edges appear a little blurry. When I increase the size of text in Microsoft Word though, it appears very clean and has crisp edges. Is there a way to do that with SFML?
Looking at the SFML sources, it appears that it is using the embedded Arial font. Yes, it can also load the .ttf font file, but I guess you didn't load it yet.
So the problem is tht SFML tries to scale the fixed-size bitmap when you are rendering the text.
To get rid of the aliasing try following this sample http://www.sfml-dev.org/tutorials/1.4/graphics-fonts.php and load the .ttf manually.

Large text appears blurry

I'm using SFML 1.6 to make a small game, and I need to display some text, so I use the sf::String class. The problem is, when I increase the size to 96pt, the edges appear a little blurry. When I increase the size of text in Microsoft Word though, it appears very clean and has crisp edges. Is there a way to do that with SFML?
Looking at the SFML sources, it appears that it is using the embedded Arial font. Yes, it can also load the .ttf font file, but I guess you didn't load it yet.
So the problem is tht SFML tries to scale the fixed-size bitmap when you are rendering the text.
To get rid of the aliasing try following this sample http://www.sfml-dev.org/tutorials/1.4/graphics-fonts.php and load the .ttf manually.

Blit transparent images with Allegro

I'm wondering if there is any possibility to draw png with transparent colors, so I can make something half-transparent. I've read this but I can't get anything to work. I also heard about alpng library but I don't know if it's able to load transparency too.
I'm using allegro 4.2.1 with the newest Dev-C++.
You need to load a 32-bit image, call set_alpha_blender() and then draw_trans_sprite(). See this discussion. TGA is the only format that Allegro 4 supports natively that is sufficient for this task. Otherwise, you'll need to look into a PNG loader add-on.
You may also want to consider switching to Allegro 5 if you are just getting started. It has a much more modern API for this type of thing.