Is there a way to get graphic transparency in IOS?
Just circling back here to see is there a way to make a graphic in iOS to have a level of transparency like on Desktop?
IOSBitmap has iOSGraphics
iOSGraphics has .Alpha properties, so yes.
Also see .cliptoPath
also, in the iosLibs I find ImageWithMaskXC
all looks promising?
SO, looking to achieve this in 2022, I cannot get it to work. A deep search of the forum finds this( our own) posts from a year ago.
@Martin_Fitzgibbons … did you have any success?
Hi Jeff,
I don’t think so as I didn’t reply back. I think I was exploring MBS but got distracted and moved on ![]()
I think the reason could be iOSGraphics is missing the BlendMode property that makes it possible to overlay drawings in a way they don’t simply overpaint. I’m pretty sure you will find the necessary declares in one of the extensions/modules/plugins that enable full CGContext access.
Then arguably Xojo can find the necessary declares too. ![]()
Hmm…
I’ll work something.
Does iOSGraphics.Alpha not do what you need?
Does iOSGraphics.Alpha not do what you need?
Nope.
That makes the whole ‘sprite’ transparent.
Imagine a square image with a cherry
I would want the cherry solid, and the rest transparent.
So that I can .drawpicture the image onto a wall, and see wall around cherry, rather than a while square on the wall with a cherry in it
MASK does that on desktop, as does a PNG image with transparency
I can find no way to take a solid image and make part of it transparent afterwards
.CliptoPath should do it… applied to the target so that I can only paste into a cherry shaped hole
But it doesn’t.
My current work around is to use a grab of the background, then pixel by pixel, copy the wanted parts from the source into, using RGBSurface
I found a bug related to transparency last month; I haven’t filed it yet. Not sure if it pertains to the OP’s problem:
Top code:
g.Scale(0.25, 0.25)
g.Transparency = 75
g.DrawPicture(DogSign, 0, 0)
Bottom code:
g.Scale(0.25, 0.25)
g.Transparency = 75
g.DrawPicture(DogSign, 0, 0, DogSign.Width, DogSign.Height, 0, 0, DogSign.Width, DogSign.Height)
'g.DrawPicture(DogSign, 0, 0, DogSign.Width, DogSign.Height) // This works too
On iOS, Graphics.Transparency only works if you use a longer DrawPicture method signature.
On macOS, the same code produces the correct result in both examples.
