1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

CoreImage : tint a PNG?

Posted by Brendan Dawes on Aug 09, 2007

Is it possible to tint a PNG with specific RGB values in a similar way you can with Flash?

Levels doesn't work in the same way - unless there's some math voodoo that I can do!

Any help would be much appreciated.

Thanks


 
Posted by Tom De Smedt on Aug 13, 2007

Hi Brendan,

I'd add a fill layer on top of the image and blend it with the hue or color mode:

coreimage = ximport("coreimage")
canvas = coreimage.canvas(500,500)
 
img = "rabbit.png"
l = canvas.layer(img)
l = canvas.layer_fill(color(1,0.5,0))
l.blend_color(80) # or blend_hue for subtler effect
 
# If the image contains transparency,
# we can mask the fill layer with a b/w version of the image
# so the transparent parts don't get colorized.
m = l.mask.layer(img)
m.filter_levels(r=0, g=0, b=0)
m.invert()
 
canvas.draw()