1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

DrawableImage: Remove a message thread dependency

This commit is contained in:
Tom Poole 2021-06-21 15:53:58 +01:00
parent efd0373525
commit 8ce68447bb
4 changed files with 31 additions and 24 deletions

View file

@ -167,23 +167,15 @@ void Drawable::setTransformToFit (const Rectangle<float>& area, RectanglePlaceme
//==============================================================================
std::unique_ptr<Drawable> Drawable::createFromImageData (const void* data, const size_t numBytes)
{
std::unique_ptr<Drawable> result;
auto image = ImageFileFormat::loadFrom (data, numBytes);
if (image.isValid())
{
auto* di = new DrawableImage();
di->setImage (image);
result.reset (di);
}
else
{
if (auto svg = parseXMLIfTagMatches (String::createStringFromData (data, (int) numBytes), "svg"))
result = Drawable::createFromSVG (*svg);
}
return std::make_unique<DrawableImage> (image);
return result;
if (auto svg = parseXMLIfTagMatches (String::createStringFromData (data, (int) numBytes), "svg"))
return Drawable::createFromSVG (*svg);
return {};
}
std::unique_ptr<Drawable> Drawable::createFromImageDataStream (InputStream& dataSource)