# "Trail" bug when using setBufferedToImage and transforms

**URL:** <https://forum.juce.com/t/trail-bug-when-using-setbufferedtoimage-and-transforms/17888>\
**Category:** General JUCE discussion\
**Created:** [May 29, 2016, 1:59pm UTC](https://forum.juce.com/t/trail-bug-when-using-setbufferedtoimage-and-transforms/17888 "2016-05-29T13:59:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yairadix](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yairadix/32/1114_2.png) [@yairadix](https://forum.juce.com/u/yairadix)\
**Post date:** [May 29, 2016, 1:59pm UTC](https://forum.juce.com/t/trail-bug-when-using-setbufferedtoimage-and-transforms/17888/1 "2016-05-29T13:59:13Z")

</div>

In this screenshot of the JUCE demo\*, the leftmost slider looks wrong:

 ![](https://us1.discourse-cdn.com/flex026/uploads/juce/original/1X/48c85cb1e93bed476a17c3dc35e2680fdc39785c.png)  
To make it happen I just enabled `s->setBufferedToImage (true);` for that slider, then ran the demo and played with the transform and this slider. In small transforms it happens.

I think that this happens due to this piece of code in juce\_Component.cpp:

```
Graphics imG (image);
LowLevelGraphicsContext& lg = imG.getInternalContext();

lg.addTransform (AffineTransform::scale (scale));

for (const Rectangle<int>* i = validArea.begin(), * const e = validArea.end(); i != e; ++i)
    lg.excludeClipRectangle (*i);

if (! owner.isOpaque())
{
    lg.setFill (Colours::transparentBlack);
    lg.fillRect (imageBounds, true);
    lg.setFill (Colours::black);
}

owner.paintEntireComponent (imG, true);

```

The `lg.fillRect (imageBounds, true);` part is performed after `lg.addTransform (AffineTransform::scale (scale));` which changes `lg`'s coordinates from image-based to component-based.

It seems that changing it to `lg.fillRect (compBounds, true);` fixes this bug.

Cheers, Yair

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [July 30, 2016, 1:50pm UTC](https://forum.juce.com/t/trail-bug-when-using-setbufferedtoimage-and-transforms/17888/2 "2016-07-30T13:50:04Z")

</div>

Sorry that this took so long and thank you for your fix. It’s on develop now.
