Strange behaviour in Image::getClippedImage?



It seems that when calling Image::duplicateIfShared() on an image aquired trough Image::getClippedImage(),  the clipped image isn't duplicated.

I have the following code snippet from my component's paint routine:

Image activeImage = image.getClippedImage(area);

// this is a custom function
multiplyImageWithColour( activeImage, avAudioLightColour.withBrightness(1.f).withAlpha(1.f));

            (int)(start * image.getWidth()), 0,
            (int)((end - start) * getWidth()),
            getHeight(), 0, 0, activeImage.getWidth(), activeImage.getHeight());

The resulting image gets drawn darker and darker, because the image gets recylced and "coloured" over and over.

This doesn't happen if I create activeImage like so:

Image activeImage = image;
activeImage = activeImage.getClippedImage(area);

Is this a bug?


Hi tim_is_tof,

you are right: there seems to be a bug in the way duplicateIfShared() handles the case when the pixel data is of type SubsectionPixelData. I've implemented a fix for this which I've sent over to Jules for his approval.

Thanks for reporting this!



Should be in newest tip now!