graphic formats
thats me

Hello, I would like to use 32 bit images in my program using the alpha value (ARGB) but I'm not sure how could it be done. First I need an image format, which supports 32 bit interface (bmp doesn't). Second, I need a library to load images of this type and convert them to BITMAP * . Finally, I do not know how to work with these images (blit(), makecol(), put/getpixel()...). Could someone help me? :(

X-G

TGA is your friend. Allegro supports it natively.

Elias

A better format is PNG, which is supported through an addon. To use the alpha channel, look at the set_alpha_blender and draw_trans_sprite functions. Also, investigate if the AllegroGL or OpenLayer addons are useful to what you want to do - they can use alpha blitting with HW acceleration.

A J

PNG is good for Alpha channel support.
althou im not sure how you go about getpixel() when it returns a signed int

Elias

[To mods: can you delete this message and move the thread away from the dev forum?]

Peter Wang
Quote:

althou im not sure how you go about getpixel() when it returns a signed int

32 bits is 32 bits, no matter if you decide to interpret it as signed or unsigned for some operations.

thats me

The case is as follows: I have a 24 bitmap and another greyscale bitmap, which could be interpreted as alpha equivalent of the same picture. If I could do a program that combines both of this images (the output can be TGA or whatever) and afterwards use the combined image in my program...
If anyone has a tip how to do that and has time for lamers :), please share it. I'm going to read all the blender stuff in the docs and if I have further problems I would ask again. Thanks.

Elias

You can do it e.g. in Gimp. Add an alpha channel, select the channel, paste the grayscale into it, then save again.

Or you can do it in Allegro, something like:

set_colorconv_mode(COLORCONV_NONE);
bmp24 = load_bitmap("24bit.bmp", NULL);
PALETTE pal;
alpha8 = load_bitmap("8bit.bmp", pal);
select_palette(pal);
BITMAP *bmp32 = create_bitmap_ex(32, w, h);
for(y = 0; y < h; y++) for(x = 0; x < w; x++) {
    c = getpixel(bmp24, x, y);
    r/g/b = getr/g/b24(c);
    a = getpixel(bmp8, x, y);
    r = getr8(a); // assuming, r/g/b is the same in the grayscale..
    putpixel(bmp32, makeacol32(r, g, b, a);
}

The code is apparently only pseudo-code, but basically, you can create a 32-bit bitmap with alpha channel using putpixel.

gnolam
Quote:

The case is as follows: I have a 24 bitmap and another greyscale bitmap, which could be interpreted as alpha equivalent of the same picture. If I could do a program that combines both of this images (the output can be TGA or whatever) and afterwards use the combined image in my program...
If anyone has a tip how to do that and has time for lamers :), please share it. I'm going to read all the blender stuff in the docs and if I have further problems I would ask again. Thanks.

Check the manual entry for set_write_alpha_blender()and do exactly what it says. :)

Thread #562538. Printed from Allegro.cc