Alpha rect

6 posts / 0 new
Last post
alfkil
alfkil's picture
Offline
Last seen: 3 months 1 week 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: 3 months 1 week 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: 3 months 1 week 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: 3 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Alpha rect

...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.

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

ChrisH
ChrisH's picture
Offline
Last seen: 4 years 3 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: 3 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Alpha rect

@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

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

Log in or register to post comments