Transparent image

I have tried to use the pixel method posted by Jason King in
https://forum.xojo.com/18611-rgbsurface-for-ios to selectively copy only color pixels to an iOSBitmap and leave whites transparent, but visibly there is still some white in color, and the result is faded.

Is there any way to render white transparent in an iOSBitmap, like Desktop does ?

There seem to be ways in the framework to do that :
http://stackoverflow.com/questions/8311049/ios-color-to-transparent-in-uiimage

&cFFFFFFFF should be white transparent.

Unless I completely misunderstood your question.

Yes, you have misunderstood the question. I know how to compose a transparent white.

I am trying to get to something like http://documentation.xojo.com/index.php/Picture.Transparent for iOS.

Have you tried using PNGs with an alpha channel?

OK. Let me explain what I am trying to achieve.

In Check Printer iOS, the user can take a picture of his signature, so the said signature be added to the check and printed at the same time. He will get a picture with a white background and blue or black lines. If he prints on white paper, it is not an issue, but if he uses a background picture, it will mess the printing.

In the Desktop version of the program, I have a setting “make white transparent”.

The pixel method works, but it is slow, and colors get somewhat faded. Since the feature exists in OS X, I suspect there is something in the framework that already does that.

So it is not as if I did not have a solution already, it is that I would like something better. I can always go for the current method, and when Xojo implements Interops (see http://www.bkeeneybriefs.com/) that will hopefully allow anybody to tap into the framework without the current hurdles of declares which require a thorough understanding of Objective C or Swift, as well as which variable types to pass and expect.

Do CGContexts exist on iOS? If so then you can set the CGBlendMode to multiply, it’s dirty but we used it in the past with some success.

If your image is greyscale, you can take a solid black image and apply your source image as a mask?

I know Core Image exists on iOS, so it would be possible to create a CIKernel in code which would adjust each pixel, and it would use the GPU. However, that a lot of trouble.

Yes they do… as a matter of fact it is the primary technology I use to draw/manipulate graphics in SWIFT… iOS even supports a “clear” color that would make things easier (just replace UIColor.white with UIColor.clear), but this of course assumes that Xojo exposes that (oh wait… sorry)… it means if someone can come up with the right declares to use…

From what I understand of what I heard at XDC, interops will enable tapping in the framework pretty much as easily as in Swift or OC. I am looking forward for that.

For the time between, you might use a part of iOSLib (from AppleLib) where you can either use the CGContext draw methods on a normal Canvas or the iOSLibCanvas which rebuilds a standard Canvas, but with more events and a direct exposure of the extended Context methods. Like on macOS Desktop, the iOSGraphics object is the CGContext, so I see nothing “dirty” about it – just adding a few methods. And yes, interops sound great!
Reminds me: I still have to add the predefined colors (including ClearColor) to the mac part.

In terms of Dirty, using the Multiply blend was a dirty technique I learned back in the 1990s for drawing images ontop of each other without masking correctly. Correctly masked images looked so much better, but most clients couldn’t tell the difference.

I’m looking forward to seeing these too.

Oh I see, thanks! Well, that’s what I am doing a lot of the time in my design business – didn’t consider it dirty :smiley:

Sorry man, am a bit of a snob when it comes to graphics work. I often end up making ‘dirty’ choices because while I’m not proud, I know that most people won’t be able to tell.

I’m also terrible with promotional material, often handing it back with corrections that I feel should be made.

Bad habit I know.

Not at all, Sam. The DTP revolution some 30 years or so ago made publishing as fast as never before, but most of the early works (and still a lot of current books) ignored a lot of aesthetic guidelines and looked really awful.
Last year, I had to cancel working for a customer because he tried to press me into ridiculous hourly rates, stating that “not one more book is sold because it is well-done and proofread.” I don’t agree with that.

Back to topic: Blendmodes are great where they are appropriate. Where they are not, a skillful image retouch is always more advisable.

But whom do I tell?

Sorry, but what little I understand about the upcoming “interops”… still sounds like a band-aid, instead of incorporating the proper lanugage features…

We cannot do more than speculate at this time. From what I read so far, I think that you are right – but how should it work else? Many are looking for simple extensions – the forum is full of feature requests like background color for controls that don’t have one. For those cases, interops sound excellent. They should bring us quite on par with XCode, where you basically have to build your subclass too. Not having to declare each API access could reduce development time by at least 50%, if I consider the time I spend for writing declares and then the logics between them. Probably even more if you don’t have to look up (or guess) the parameter types.

More sophisticated classes will still demand a bit more than basic knowledge about the API hierarchy (like Responder/View/etc. classes on Apple’s systems), but basically everyone who manipulates Canvases is very close to that knowledge. I am very certain one of Paul’s webinars will help to close that gap in time.

If even a userControl should be added to Desktop that saves us from Damocles’ sword of messing with the views: Then we’d be very close to the possible optimum. The Xojo engineers are brilliant, but adding a fully automatic API class builder would IMHO demand more than Genius. Not that I wouldn’t trust them to tackle something like that too, but rather in the long run.

Oh, and another anecdote, @Sam: Just remembered I ran into a friend of mine recently. I once did a logo for a musical he composed, and he told me he is glad to hear that I am shifting my work more towards programming. He thought I would not fit into a design job because I manually masked each grass leaf. People can say so very wrong things …

I will take that kind of band aid any day, over the existing pesky declares. At least, we will be pretty much on par with Swift, being able to call the framework without losing a handful of hair.

Look at my current predicament. I pretty much know where to look in the framework to make it happen, but between my crude knowledge of OC and the very real competence it takes to use declare, I know it would take me a full week or so of very frustrating work to maybe get to a workable result.

Sure, if Xojo was willing to provide the same kind of property and methods that have been going without saying in Desktop for 20 years, it would a piece of cake. Unfortunately, we don’t even have bread, let alone cake, just crumbs of what Xojo used to be.

Interops, which we should still have to wait for until 2017R4 as far as I understood, will be a breath of fresh air.

In the meantime, I will probably tweak a little bit my pixel method and go for more interesting endeavours.

IOSCanvas.Paint( g As IOSGraphics )
g has a Alpha property.

Derk, thank you, but please read all the tread.