Alpha maps? (2d question)

BlitzMax Forums/BlitzMax Beginners Area/Alpha maps? (2d question)

DH(Posted 2005) [#1]
So is it possible to add an alpha channel to an image, load it into blitzmax, and draw it using the alpha channel as a transparancy refference (similar to blitz3d and alpha channels of a texture)?

If so, what is the general way to go about doing it (the documents of blitzmax are very vague)?

Thanks,


ImaginaryHuman(Posted 2005) [#2]
Yes. Whatever paint/image-processing program you use, it will need to support saving of a picture that includes an alpha channel. Your best bet is to save it as a PNG file. Probably you will have set up your alpha channel within that software, so when you save it should let you save the alpha channel as part of the file.

Then you load it into Blitz as normal with something like LoadImage()

Then you will need to choose SetBlend ALPHABLEND to choose the correct drawing mode, and then DrawImage to draw it. It should draw the image with different transparency for every pixel based on the alpha channel.


DH(Posted 2005) [#3]
@angeldaniel
That doesn't seem to work. I saved the file as both a bmp and a png preserving the alpha channel (bmp doesnt load in blitzmax with 32 bit, but png will), yet when i load it into blitz max using the method you described, it shows all the pixels of the image that should be transparent.

I know the alpha channel is present in the file because I can load it into b3d and apply it as an alpha'ed texture and it shows up correct.


Gabriel(Posted 2005) [#4]
If you used Photoshop to create that PNG, forget about alpha channels. Photoshop uses plain level transparency when exporting PNG's with alpha. Just delete the background and all transparency on the above levels will be exported into the alpha channel when you save as PNG.


DH(Posted 2005) [#5]
@sybixsus
I dont quite understand that. Although, i dont understand why 32 bit bmp's aren't supported either.

Can you explain a bit better?

Thanks,


Dreamora(Posted 2005) [#6]
because BMP are meant for 24bit in their original form. its quite uncommon to support 32bit there as 24bit are already far too large with no more quality than png.

what sybixsus meant: when creating your image in photoshop, choose transparent background on creation and the alpha will be exported to png when saving. with a non transparent background this one will "block" the alpha.


DH(Posted 2005) [#7]
because BMP are meant for 24bit in their original form. its quite uncommon to support 32bit there as 24bit are already far too large with no more quality than png.


Correction: 32 bmp's hold an alpha channel which gives you more control over what is displayed of that image.

It is supported in Blitz3d, which is quite a few years old now.

WinXP has native support for it (all image viewers in xp support 32 bit bmps).

Photoshop 7 and paintshoppro 8 support them.



what sybixsus meant: when creating your image in photoshop, choose transparent background on creation and the alpha will be exported to png when saving. with a non transparent background this one will "block" the alpha.

But I want to retain the alpha information.


Gabriel(Posted 2005) [#8]
But I want to retain the alpha information.


And that's how you do it. You just don't put the alpha in a separate channel. The alpha value of each pixel is saved instead.


Yan(Posted 2005) [#9]
When Photoshop exports PNGs, it uses the LAYERS transparency to create the PNGs alpha channel.

[edit]...I got distracted mid post again...[/edit]


DH(Posted 2005) [#10]
Well, i got it to work the way you described. I will have to see if the png keeps the level of detail I need.

thanks a ton for the help.