# Recolouring an image

**URL:** <https://forum.juce.com/t/recolouring-an-image/24715>\
**Category:** General JUCE discussion\
**Created:** [October 18, 2017, 7:31pm UTC](https://forum.juce.com/t/recolouring-an-image/24715 "2017-10-18T19:31:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [October 18, 2017, 7:31pm UTC](https://forum.juce.com/t/recolouring-an-image/24715/1 "2017-10-18T19:31:54Z")

</div>

If I’ve got a PNG in transparent and black and I’d like to change the black so it renders in some other colour is there a convenient way of doing it?

---

<div class="post-metadata">

**Author:** ![Toddler-Boy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/toddler-boy/32/2007_2.png) [@Toddler-Boy](https://forum.juce.com/u/Toddler-Boy)\
**Post date:** [October 18, 2017, 8:18pm UTC](https://forum.juce.com/t/recolouring-an-image/24715/2 "2017-10-18T20:18:17Z")

</div>

In the drawImage call you can pass “fillAlphaChannelWithCurrentBrush”. So if you set that variable to “true” and put a “setColour (Colours::red)” before the drawImage call, all pixels get replaced with red-pixels. You can use a different alpha to blend the original image with your colour too. e.g.

```auto
setColour (Colours::red.withAlpha (0.5f));
drawImageAt (image, 0, 0, true);

```

Would draw you image with 50% red and 50% your pixel colours. It respects the alpha of each pixel, so for 100% transparent pixels, they will stay transparent etc.

Cheers,  
Mike

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 19, 2017, 8:11am UTC](https://forum.juce.com/t/recolouring-an-image/24715/3 "2017-10-19T08:11:00Z")

</div>

You can also pass a semi-transparent image into Graphics::reduceClipRegion so that it creates a masked area, and then you can paint whatever fill patterns you like into it.

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [October 19, 2017, 8:11am UTC](https://forum.juce.com/t/recolouring-an-image/24715/4 "2017-10-19T08:11:22Z")

</div>

Thank you both!

---

<div class="post-metadata">

**Author:** ![Severalun](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Severalun](https://forum.juce.com/u/Severalun)\
**Post date:** [June 7, 2021, 3:49am UTC](https://forum.juce.com/t/recolouring-an-image/24715/5 "2021-06-07T03:49:04Z")

</div>

Awesome advice. Just saw your post. Keep it up.
