![]() |
|
savepng and transparency |
Johan Halmén
Member #1,550
September 2001
|
I want to create a png file with alpha transparency. I've downloaded loadpng and it loads png files ok, but when I try to save a BITMAP, I get a rgba image with nothing in the channels. How should I create the BITMAP in my Allegro app and how should I use the save functions in loadpng to get what I want. My application is an update of my Eggifyer, which reads an image and mapps it on an egg. Now I want a transparent surrounding for the egg and a semi-transparent shadow that fades to the edges. All that looks fine in the application on my screen, but I want it saved so that I could place the egg on a web site. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
Peter Wang
Member #23
April 2000
|
Have you made sure the image is 32-bit? I don't remember whether it works but it looks like I put in code to specifically deal with 32-bit BITMAPs.
|
Johan Halmén
Member #1,550
September 2001
|
Well I think it is 32 bit. I do set_color_depth(32), then I do set_gfx_mode(). After that each create_bitmap() should create a 32 bit bitmap, right? The saved png has four channels but the alpha is black. I managed to separate the channels, revealing the image in the rgb channels. I guess my problem is drawing the image in the first place. I've been RTFM, but I haven't figured out when the drawing functions actually change the alpha value for a pixel in the bitmap. I draw the image pixel by pixel. For the background I imagine I could do: a = 0; col = makeacol32(r, g, b, a); putpixel(bmp, x, y, col); and for the object I have methods for calculating r, g, b and a. a is 255 except for the edge, where I interpolate to get rid of crispiness, kind of anti-aliasing. But the result looks like if a would calculate to 0 for the whole image. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
Peter Wang
Member #23
April 2000
|
Allegro's alpha support is pretty... idiosyncratic. I managed to get the following program to work though. The trick was to set_color_depth(32); Otherwise you might look into set_write_alpha_blender().
|
Johan Halmén
Member #1,550
September 2001
|
Thanks for that! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
|