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?
Mon, 2013-06-24 02:17
#1
Alpha rect
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?
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).
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):
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
@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
@ChrisH
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