// If this is hit, there's already another BitmapData or Graphics context active on this
// image. Only one BitmapData or Graphics context may be active on an Image at a time.
jassert (state != State::drawing);
const Image::BitmapData destData (destImage, area.getX(), area.getY(), area.getWidth(), area.getHeight(),
Image::BitmapData::writeOnly);
uint8* line = destData.data;
const Image::BitmapData srcData (sourceImage, Image::BitmapData::readOnly);
The above isn’t legal anymore if destImage == sourceImage
. In that case you should make only one Image::BitmapData
that has read / write access.
Code to reproduce:
//==============================================================================
void MainComponent::paint (juce::Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
int w = getWidth();
int h = getHeight();
juce::Image blurredImage (juce::Image::ARGB, w, h, true);
{
juce::Graphics gi (blurredImage);
gi.fillAll (juce::Colours::blue);
gi.setColour (juce::Colours::red);
gi.drawRect (w/4, h/4, w/2, h/2, 5);
}
juce::ImageConvolutionKernel blur (12);
blur.createGaussianBlur (6);
blur.applyToImage (blurredImage, blurredImage, blurredImage.getBounds());
g.drawImageAt (blurredImage, 0, 0);
}