Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Black outline when saving files

This thread is locked; no one can reply to it. rss feed Print
Black outline when saving files
Aikei_c
Member #14,871
January 2013
avatar

Hello everyone! It's been awhile since I last posted here.
I ran into an issue with allegro 5: when I save something, sometimes allegro adds black outline, which shouldn't be there. To explain you what I mean, I attach these two images. The first one is original, the second one is the first image loaded as ALLEGRO_BITMAP* and then resaved. You could download and magnify it to see it better if you don't see any difference at first.
What is the cause of this and is there any way to get rid of it? I've made a helper CLI programm for batch renaming/converting/rotating images, as well as cutting from spritesheets/creating spritesheets from several files, and this issue really prevents me from using it.

608940
608941

Todd Cope
Member #998
November 2000
avatar

If you are going to be saving loaded images, you need to turn off pre-multiplied alpha. With pre-multiplied alpha turned on, which is the default, the pixel data is modified on load. This is good for the most common use cases, since pre-multiplied alpha gives more accurate blending.

Use al_set_new_bitmap_flags(ALLEGRO_NO_PREMULTIPLIED_ALPHA) before loading any images you intend to save. If you need to display bitmaps loaded this way on-screen, be sure to use al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA) before drawing to the display.

Aikei_c
Member #14,871
January 2013
avatar

Thanks a lot, Todd! This really helped.

Go to: