Advertisement

PNG alpha

Started by July 05, 2004 12:48 PM
2 comments, last by Jiia 20 years, 4 months ago
I have this problem with PNG alpha and cant solve it. To start with, I used to use TGA for my textures in my game, however, PNG showed out to be better on most things and I started to use that instead. Well, with TGA I used a mask-alpha, and even if PNG also has support for alpha - it's not the same type. With Paint Shop Pro you can chose "Load Mask From Alpha Channel", and with a TGA picture you now get (if you now have a mask) a black and white alpha-mask. I use this alpha-mask to make my textures transparent. However, with PNG, I just can't save it as a mask! Even if I have saved it as alpha, it says "Image does not contain alpha-channel" when I klick at "Load Mask...". So, I have to rebuild large parts of my code to make PNG work the same way as TGA did before, and I was hoping to save som time so ... anyone here who knows how to solve this problem? I need a PNG with a alpha-mask, that's it!
*.png uses an alpha channel...
the alpha channel is the 4th channel...
red green blue alpha
dont think it matters what u call the 4th channel but i always call it alpha 1

i did a quick check on my cpu, with photoshop and it doesnt seem to regard a mask as an alpha channel.. as it doesnt give me the option to tick "exclude alpha channel" when im saving ...

The quick and dirty way to make the pic's u have work is to duplicate one of the rgb channels as the alpha channel...use "actions" and "batch" to do tonnes in matter of minutes .. use levels on the alpha channel if there isnt enough showing up due to a really dark alpha channel..use batch again if necessary.. sometimes this technique pans out.. sometimes it doesnt..it worked for me a fair bit though..sorry if psp doesnt have something similiar?
If your code can load png's with transparency then this should work fine...

im not saying its impossible to use a mask instead of a whole new channel, but its the only way i have done it.. :/

Advertisement
Can't you work with TGA's and in the end do a Save As... to a png?
Dude, finally someone else who has these problems! Are you using PSP 8? Paint Shop Pro seems to save TGA files in a format that gets totally screwed up when loaded from 3D Studio or Direct3DX. Was that your problem as well? I've been filtering my transparent textures through Photoshop (by just loading and saving them) just to have them work.

Just tested this. To save as PNG, you need to leave the mask in the image. You don't need to save it to the alpha channel with PNGs. To test this out, create a new image, promote background layer, use the eraser tool and throw some lines on it, then save as PNG. You can load it back in the same way.

If you want to edit the mask like a greyscale image, you can Go Layers->NewMaskLayer->FromImage->SourceOpacity, then copy the layer and paste as a new image (Ctrl + V). Then remove all transparency from the original image and flatten it. Now you have two seperate images, mask and color. Make sure to add a layer and flatten the mask image because there are issues with that in PSP.

To put the mask back into the original image, just do the Layer->NewMaskLayer thing again on the color image, and just copy and paste the mask image into that layer (Ctrl + E). You can then save it as PNG, or you can combine the mask and color by right clicking on the mask layer and selecting "Delete", then clicking "yes" when it asks if you want to combine them.

Sorry for the overly detailed explanation, but I was somewhat figuring this out as I go. I'm definitely using PNGs from now on :)

This topic is closed to new replies.

Advertisement