PDA

View Full Version : CG Help: how to draw on PNG transparent plane?


Parduz
September 28th, 2007, 10:53 AM
1st question:
"PNGs have a "transparency" layer (other than R,G, and B layers) and this plane is used to do a "per pixel" alphablending with what is under the PNG"
Is this true?

2nd question:
HOW to draw on the transparency layer? I mean: suppose that i already have a PNG; now i want to add semi-transparent area, or do a gradient from complete opaque to complete transparent, etc...
WHAT should i do?

At office i own PaintShopPro, which works with layers, but i cant figure how to draw on the transparent part without changing the "RGB" image.

Can you pls help me?
I will hate to write a complete VB app just to do this task....

ChilliDog
September 28th, 2007, 11:54 PM
I assume that's true but after it's compiled into the PNG file the layers are flattened. You don't really need to access it's original layers, however. As long as you have a program that works with layers, as you do, you should be fine. Just add another layer over top of the original image, which is on it's own layer. Put your gradient or whatever on the new layer above that. Having things on separate layers makes everything SOO much easier.

I hope that was somewhat helpful, or even made sense at all? I think I understood your question correctly but it's possible that I didn't.

Parduz
September 29th, 2007, 08:46 AM
I assume that's true but after it's compiled into the PNG file the layers are flattened.
This is not really true. If we're talking about Photoshop (or PaintShopPro) "layer objects" (the things you see in the layer window) then is true.
But PNGs still mantains the transparent infos in it:
compression thing apart, they're made of 32 bits per pixels, that's equal to 4 bytes per pixels (think at a pixel as a "column" built with 4 "cubes": you see the column from the top): the first 3 bytes are the Red,Green,Blue values. The fourth, in case of PNGs, is the amount of transparency.

While, as a programmer, i'm able to access these 4th bytes by writing a program for this scope, i really need to know how to draw on it with usual graphic programs.

You don't really need to access it's original layers, however. As long as you have a program that works with layers, as you do, you should be fine. Just add another layer over top of the original image, which is on it's own layer. Put your gradient or whatever on the new layer above that. Having things on separate layers makes everything SOO much easier.
True and false :)
If i have to build a PNG from non transparent images (JPGs, BMPs, etc) i can make this "transparency" layer. But what if i want to change an existing PNGs?
And, finally: haveing this new layer: HOW it have to be "combined" with the image to make it the "transparent" layer?

Thanks for your answer(s) :)