Charmed Quark Systems, Ltd. - Support Forums and Community
Transparent images in RIVA? - Printable Version

+- Charmed Quark Systems, Ltd. - Support Forums and Community (https://www.charmedquark.com/vb_forums)
+-- Forum: Third Party Development (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=8)
+--- Forum: Third Party Development (General) (https://www.charmedquark.com/vb_forums/forumdisplay.php?fid=22)
+--- Thread: Transparent images in RIVA? (/showthread.php?tid=7019)

Pages: 1 2 3 4


Transparent images in RIVA? - SamVimes2 - 01-13-2011

So the problem images display properly in the C++ RIVA client. The plot thickens!


Transparent images in RIVA? - Dean Roddey - 01-13-2011

Oh, OK, it's coming back to me now. What happens is that the RIVA client gets a regular DrawBitmap command. However, when it goes to look into its cache for this image, it'll see that it has a transparency color to use, and therefore it should draw it using the transparency color. So the transparency color isn't sent in the command, and there's no special command to indicate this. It's just that the image itself is in the repository as a color transparency image, and therefore it'll only ever be drawn in that way.

So, when the RIVA client requests an image, the image start has a set of flags and a transparency color. If the 0th bit in the flags is set, then the transparency color is there and should be stored along with the image, and the image marked as a color transparency based image and so any time it's asked to draw the image, the RIVA client should use that color based transparency to draw it.


Transparent images in RIVA? - brianmount - 01-13-2011

So that's the bit that, in the documentation, says, "0 - This is only set if the 1st bit was set in the request." Is that right? I will not be setting the first bit in the request, because my client does understand alpha channels. But bit 0 in the response can, if I understand you, be set anyway, if the template was set up with an override transparency color. If I do detect such a color in the download response, it replaces whatever transparency color is in the original image, if any. And if the image is an alpha-based image? Do I set a transparent color anyway, by forcing the alpha to transparent for any pixel with a matching color?


Transparent images in RIVA? - Dean Roddey - 01-13-2011

If the 0th bit in the response is set, you should use the transparency color. Either by itself, i.e. regular color based transparency draw sprite style, if the image has no alpha channel, or in conjunction with the alpha channel if that is present.

Though, the latter is so seldom required that if you chose to ignore that I don't think it would be an issue. Hardly anyone is going to turn on color based transparency on an image that has alpha transparency.

That also means that, when you get the image down, if the 0th bit is set, you can pre-mask it, so that you only have to do two of the required sprite style drawing steps each time you redraw it, instead of all three steps. But, if your OS only provides a single operation, it wouldn't matter so you wouldn't do that. For me I pre-mask those images in the cache. So all I have to do is create the hole in the screen, and then blit the image into the hole.


Transparent images in RIVA? - Fonceur - 01-13-2011

So is the color to use as transparent supposed to be in the other bits or it's found somewhere else?


Transparent images in RIVA? - Dean Roddey - 01-13-2011

It's in the initial image start response when you request an image. You should store in the image cache along with the image (and you can of course store some flag to indicate that it's one that should be drawn using color transparency.


Transparent images in RIVA? - brianmount - 01-15-2011

I have been experimenting, and the flags and color of the returned ReqImgStart message are always 0 unless I set flags to 2 in the ReqImgDownload message. Even if I set flags to 3 (which should set the same bit), I see nothing. But if I set flags to 2, the flags come back as 1, and I get a transparent color. I think that means that CQC, since I have told it that I can't understand alpha, is converting my images to color transparency. But that's not what I want. I can in fact understand alpha. I only need the transparency color if one has been set in the Interface Editor. Do you have any suggestion about what I should do? How does the C++ Riva client set its flags? That isn't the client that uses the simple protocol, is it?


Transparent images in RIVA? - Dean Roddey - 01-15-2011

You should set the flags to zero. The only images that should come to you with a color transparency are ones that are in the repository as color transparency based. So, unless you have any in your repository that are, you won't see any with a transparency color.


Transparent images in RIVA? - brianmount - 01-15-2011

There are three different kinds of images on the template in question. Alpha-based images, color-transparency images, and images without color transparency, where Sam Vimes has set a transparent color in the Interface Editor. All three types look fine in the Interface Editor, and the first two look fine on the iPhone (and in taRiva, as I understand it), but the last kind -- with the transparent color defined outside of the file itself -- does not show up as transparent. I send my image request with flags set to 0, and the response also has flags of 0, and no transparent color, even though one was set in the Interface Editor.

I have attached a zip of the graphics file. As you can see, it's a PNG file with no transparent color defined. One easily could be defined, but for whatever reason it was not. Sam Vimes added this image to his template, set the transparent color to white, and voila! it looks fine in the Interface Editor. But not on the iPhone. Can you suggest anything I might do to my client to remedy this situation? Thanks.


Transparent images in RIVA? - Dean Roddey - 01-15-2011

I'll take a look at here in a bit...