PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

CGapiRGBASurface, PNG and Photoshop

I'm trying to create a PNG (24 bit) with an alpha surface in Photoshop so I can alphblend an image with the background using CGapiRGBASurface. I can get 'normal' transparency to work, but I can't save the alpha channel. Somebody got any tips?

Maurice
I'm not really sure what you mean.. Just save the image as PNG with one layer with alpha information and it should work immediately.
Not sure about Photoshop, but in PaintShop Pro you create a new image with 'Transparent' as the background color setting, then place your image on another layer. Then you simply save it as a png format.
If you create an extra channel is photoshop for alpha and save it. Photoshop discards the channel.
I also looked at PaintShop Pro but since the program has a nice learning curve I was unable to test it good.

Maurice
maurice: for the PNG export to work your image should have 0 alpha channels. You should only have 3 channels (RGB), and one layer.

Test this by:
(1) Create a new image.
(2) Using the erasor tool, simply erase parts of the background layer. They will show as a grid pattern.
(3) Export as PNG
(4) Import to GapiDraw and AlphaBltFast

The parts you erased in the background layer will now be transparent.
Aha! I get it. But can you create 255 alpha values this way? Or do you still have to use the old way (2 images below each other)?

Maurice
Yes, Photoshop supports variable transparancy in each layer (up to 255 levels). You no longer need to use the old way with two images...
spacemonkey · 09 Jun 2003, 12:54 UTC
I played with this quite a bit and to be honest it drove me nuts... The conclusion I came to is that photoshop was by far the best tool for editing RGBA images with all 4 layers... Giving nice access to a greyscale 255 levels of alpha surface and everything.

HOWEVER, the photoshop PNG export mechanism does not support Alpha layers properly. What I've gone for in the end is using photoshop for the editing, then save as a photoshop file (which does work properly with alpha) and then using some other tool to convert the photoshop files to PNG. This is very annoying but on playing around with the GIMP, PaintShop Pro and MacroMedia Fireworks MX I found that Photoshop was the only one for editing this stuff. I found the easiest one that properly supports PNG for converting the files was MacroMedia Fireworks.

In the GIMP you can access all layers by splitting it into seperate images and editing them individually (one image for red, one for blue etc) and then recombining them at the end, this wasn't too bad to use (and free) but mine kept crashing a bit. In PaintShop Pro and Fireworks I found the editing tools for channel editing like this to be too hard (although this may be my lack of experience with these products).

Hope that helps.
Another option is to use Photoshop 5.5

This was a common issue explored on the mod sites for Tribes 2 since they to used alpha PNGs. Photoshop 6 and up don't save PNGs properly, but 5.5 has excellent PNG save support.

Supposedly there are some plugins for newer versions of photoshop to remedy the problem, but I've had no luck with them. You may want to search for some and see if you can get 'em working.
spacemonkey · 10 Jun 2003, 14:06 UTC
Curiously I found Photoshop 5.5 to be a problem too. What it seemed to do for me was save the PNG with alpha, the alpha was saved perfectly but the RGB layers had the alpha applied to them and then saved.

So the alpha would always be fine but after each successive save the image would become more and more washed out because the alpha channel was being averaged (or something) against the 3 color channels. Might have been something I was doing wrong tho...

Any idea what the export filters I need for Photoshop 6 are? I tried a couple but they didn't seem to help...
What works in Photoshop 6 is what Johan said earlier. Use the erase tool and set the required alpha value in the slider on the top bar.
If you save it (File->Save As, haven't tested Save For The Web) you will have a PNG with 256 alpha values.


Maurice
You could also load an alpha channel as selection, and them simply press Erase (Command+Backspace) to create a transparent image...
Johan wrote:maurice: for the PNG export to work your image should have 0 alpha channels. You should only have 3 channels (RGB), and one layer.

Test this by:
(1) Create a new image.
(2) Using the erasor tool, simply erase parts of the background layer. They will show as a grid pattern.
(3) Export as PNG
(4) Import to GapiDraw and AlphaBltFast

The parts you erased in the background layer will now be transparent.

I know this is old news, but I just want to say that you can do the same thing in PaintShop Pro. Here is how:

- Create a new image, select transparent as the background color.
- Draw something.
- Use the eraser to erase anything.
- Save as PNG. PSP will tell you that the file will be merged. Say yes.

It seems that as soon as you use the eraser, the image is given an alpha channel.

--Eric