1

I'm trying to tint an image. But this time a more tricky variant.

  • The image has got saturation, brightness and alpha information (sadly as RGBA), which should not be discarded (saturation for black shadow).

  • The tint color has got hue, saturation, brightness and alpha information (sadly also as RGBA) which also should not be discarded.

  • As I imagine it, each HSBA component (except to hue) should be multiplied to have full control about the tinted image - e.g. when I provide a less bright tint color, the image brightness should also be scaled down.

So, something like:

(h,s,b,a) = (h_tint, s_tint*s_image, b_tint*b_image, a_tint*a_image)

I searched the internet, but this procedure does not seem to be common, even when ignoring the alpha channel (or even the saturation too) for the moment.

I'd need it in iOS, but I didn't even find such a layer blend mode in Photoshop. I've tried (in iOS and if existing in Photoshop):

  • Multiply - does not look at all like what I want
  • Darken - not really
  • Color Dodge - at least somewhat usable, but not really right
  • Plus Darker - also ok, but not really
  • Color / Luminosity / Hue - these would have been my favourites, but they discard the tint's saturation and brightness values instead of multiplicating them. But maybe if there is a way of applying the missing saturation and brightness afterwards?

So, has the described blend mode a common name / would it make sense?

Any ideas on how to do this in iOS? (I'm aware of the Apple Developer Guide and Reference, and the stackoverflow questions about tinting and overlaying)

Community
  • 1
  • 1
fabb
  • 11,660
  • 13
  • 67
  • 111
  • Ok, I'll probably go with `Luminosity`/`Color` as it produces the least effort with acceptable results. The result still is too light for darker wanted colors. – fabb Sep 10 '11 at 18:15
  • BTW, I learned that Luminosity != Brightness (HSB) != Lightness (HSL) – fabb Sep 10 '11 at 18:16

1 Answers1

1

You can create a CGBitmapContextRef that's backed by data under your control, in a known format. You can then draw your image into that context. Now you have the data for the image in a known format. You can now do whatever math you like on the pixels. Once you're done mucking about with the pixels, you can create a CGImageRef from the CGContextRef.

The math is up to you.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • So this method is not common? – fabb Sep 10 '11 at 09:01
  • @fabb: I don't really know, I don't do much with graphical programming. But you indicated that what you want doesn't match any of the blend modes offered by CoreGraphics, so your only real alternative is mucking about with the pixel data. – Lily Ballard Sep 10 '11 at 22:49