![]() |
|
graphic formats |
thats me
Member #5,501
February 2005
|
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
Member #856
December 2000
![]() |
TGA is your friend. Allegro supports it natively. -- |
Elias
Member #358
May 2000
|
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
Member #3,025
December 2002
![]() |
PNG is good for Alpha channel support. ___________________________ |
Elias
Member #358
May 2000
|
[To mods: can you delete this message and move the thread away from the dev forum?] -- |
Peter Wang
Member #23
April 2000
|
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
Member #5,501
February 2005
|
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... |
Elias
Member #358
May 2000
|
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
Member #2,030
March 2002
![]() |
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...
Check the manual entry for set_write_alpha_blender()and do exactly what it says. -- |
|