Oops, well also in CoreGraphicsImage::createImage the calculation is incorrect.
But after fixing all cases i still experience a crash when loading and drawing an image with these dimensions.
So in short, guys can you help me out?
If i load this huge image, JUCE will crash.
It will only crash if you fix the size calculation, if not the size becomes so large (overflow) that it will fail allocating the memory for the bitmapData, so it won’t try to do anything. So although the code looks safe it’s actually wrong.
When calculation is fixed, bitmapData will be valid and Image is loaded.
But when i try to draw it, it fails in CoreGraphicsContext::drawImage.
As you see in the snippet i’m actually scaling the image. If i just call drawImageAt(image, 0,0); it actually works fine.
Here is the code snippet.
HUGE.jpg is an Image with size 32000 × 19202
Image image = ImageFileFormat::loadFrom(File("HUGE.jpg"));
Image thumb(Image::ARGB, 160, 120, true);
g.drawImageWithin( image, 0, 0, thumb.getWidth(), thumb.getHeight(), RectanglePlacement( RectanglePlacement::centred ), false );
g.drawRect(0, 0, thumb.getWidth(), thumb.getHeight(), 10.0);
Here is the file: