Strange behaviour in Image::getClippedImage?

Hi,

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);
activeImage.duplicateIfShared();

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

g.drawImage(activeImage,
            (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.duplicateIfShared();
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!

Fabian

Should be in newest tip now!