Alpha rect

6 posts / 0 new
Last post
alfkil
alfkil's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-10 22:02
Alpha rect

Another stupid question: How does one do a RectFill with an alpha value without resorting to CompositeTags and COMPSRC_SOLIDCOLOR (which will revert to software render)? Using IGraphics->SetRPAttrs(RPTAG_APenColor) does not work, because it ignores the alpha (see autodoc). This seems to also be the case with p96RectFill(). Help?

thomas
thomas's picture
Offline
Last seen: 2 hours 57 min ago
Joined: 2011-05-16 14:23
I don't think it is possible

I don't think it is possible to apply an alpha mask with traditional graphics functions. You might have to [p96]ReadPixelArray, manually apply the changes to the RGB values and [p96]WritePixelArray it back. Why don't you want to use CompositeTags?

alfkil
alfkil's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-10 22:02
I was hoping that there was

I was hoping that there was another possibility than CompositeTags, because as I stated it reverts to software render when using COMPSRC_SOLIDCOLOR. Another way I have tried is to use a small temp bitmap, but then it's the same problem all over (you have to use Composite to make the temp bm filled with solid+alpha).

Hans
Hans's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 2010-12-09 22:04
...This seems to also be the

...This seems to also be the case with p96RectFill(). Help?

P96RectFill() does support writing to the alpha channel, but doesn't support alpha blending. What I mean by this is, p96RectFill() will fill a rectangle with the exact ARGB data that you specify (provided that the target bitmap has an alpha channel). It's a fill operation, not a composite operation.

If you use the bitmap containing the filled rectangle with CompositeTags(), the alpha data will be used for compositing as you'd expect. So, if you want to render an alpha-blended solid rectangle, use p96RectFill()** to render the colour + alpha of your choice to a small bitmap, and then use that bitmap with CompositeTags().

Hans


** For now. At some point I expect that the graphics library itself will be able to handle alpha channels. So, I hope that everyone is obeying the following part of the SetRPAttrs() documentation (emphasis added by me):

The alpha part is currently ignored and should be set to 0xFF.

Failure to do so will cause trouble when alpha blending is supported.

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project.
http://keasigmadelta.co.nz/ - more of my software.

ChrisH
ChrisH's picture
Offline
Last seen: 3 years 7 months ago
Joined: 2010-12-07 20:22
@Hans It's a real shame that

@Hans
It's a real shame that 0x00 wasn't used to represent opaque alpha, as then non-alpha-using programs would work without having to be specially adapted.


Author of the PortablE programming language.

I love using Amiga OS4.1 on my X1000 & Sam440 :-D

Hans
Hans's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 2010-12-09 22:04
@ChrisH It's a real shame

@ChrisH

It's a real shame that 0x00 wasn't used to represent opaque alpha, as then non-alpha-using programs would work without having to be specially adapted.

I disagree. AFAIK, the bit that I quoted instructing developers to add 0xFF for the alpha channel has been in there since the RPTAG_APenColor and RPTAG_BPenColor tags were added. So long as developers followed what the documentation said their software will work without needing to be "specially adapted."

Added to that, inverting the meaning of the alpha channel from what everybody else uses, would itself be a source of confusion.

Hans

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project.
http://keasigmadelta.co.nz/ - more of my software.

Log in or register to post comments