Unable to Save image as .JPG



In my MAC application, I am not able to save image in .JPG format .

I am creating a Image like this …

Image* buffImage = pComponent->createComponentSnapshot( Rectangle<int>(0, 0, pComponent->getWidth(), 

Even though i set Opaque as TRUE, Juce Creates an ARGB image under a FLAG USE_COREGRAPHICS_RENDERING …
As jpeg doesnt have Transperancy, its not able to Encode the raw buffer as JPG …

If i set USE_COREGRAPHICS_RENDERING as 0 in Juce_mac_NativeIncludes.h, Everything works … I am able to save the image in .JPG format …

Can u help me understand why USE_COREGRAPHICS_RENDERING is enabled by default in MAC if there are issues with saving as .JPG format .


Sorry, I didn’t realise there was a problem with that!

The reason is that to use CoreGraphics, all Images have to use an alpha channel internally. I should have added a workaround for this anyway, which just requires a simple tweak, in juce_JPEGLoader.cpp:

[code]bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out)
using namespace jpeglibNamespace;
using namespace JPEGHelpers;

if (image.hasAlphaChannel())
    Image opaqueImage (Image::RGB, image.getWidth(), image.getHeight(), false, Image::SoftwareImage);
        Graphics g (opaqueImage);
        g.fillAll (Colours::white);
        g.drawImageAt (image, 0, 0);

    return writeImageToStream (opaqueImage, out);