Added a new PngImage utility class that wraps libpng. This replaces the use of OpenImageIO in O3DE (although OpenImageIO is still a build dependency for now).
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <Atom/Utils/DdsFile.h>
|
||||
#include <Atom/Utils/PpmFile.h>
|
||||
#include <Atom/Utils/PngFile.h>
|
||||
|
||||
#include <AzCore/Serialization/Json/JsonUtils.h>
|
||||
#include <AzCore/Jobs/JobFunction.h>
|
||||
@@ -86,26 +87,21 @@ namespace AZ
|
||||
jobCompletion.StartAndWaitForCompletion();
|
||||
}
|
||||
|
||||
using namespace OIIO;
|
||||
AZStd::unique_ptr<ImageOutput> out = ImageOutput::create(outputFilePath.c_str());
|
||||
if (out)
|
||||
{
|
||||
ImageSpec spec(
|
||||
readbackResult.m_imageDescriptor.m_size.m_width,
|
||||
readbackResult.m_imageDescriptor.m_size.m_height,
|
||||
numChannels
|
||||
);
|
||||
spec.attribute("png:compressionLevel", r_pngCompressionLevel);
|
||||
PngImage image = PngImage::Create(readbackResult.m_imageDescriptor.m_size, readbackResult.m_imageDescriptor.m_format, *buffer);
|
||||
|
||||
if (out->open(outputFilePath.c_str(), spec))
|
||||
{
|
||||
out->write_image(TypeDesc::UINT8, buffer->data());
|
||||
out->close();
|
||||
return FrameCaptureOutputResult{FrameCaptureResult::Success, AZStd::nullopt};
|
||||
}
|
||||
PngImage::SaveSettings saveSettings;
|
||||
saveSettings.m_compressionLevel = r_pngCompressionLevel;
|
||||
// We should probably strip alpha to save space, especially for automated test screenshots. Alpha is left in to maintain
|
||||
// prior behavior, changing this is out of scope for the current task. Note, it would have bit of a cascade effect where
|
||||
// AtomSampleViewer's ScriptReporter assumes an RGBA image.
|
||||
saveSettings.m_stripAlpha = false;
|
||||
|
||||
if(image && image.Save(outputFilePath.c_str(), saveSettings))
|
||||
{
|
||||
return FrameCaptureOutputResult{FrameCaptureResult::Success, AZStd::nullopt};
|
||||
}
|
||||
|
||||
return FrameCaptureOutputResult{FrameCaptureResult::InternalError, "Unable to save frame capture output to " + outputFilePath};
|
||||
return FrameCaptureOutputResult{FrameCaptureResult::InternalError, "Unable to save frame capture output to '" + outputFilePath + "'"};
|
||||
}
|
||||
|
||||
FrameCaptureOutputResult DdsFrameCaptureOutput(
|
||||
|
||||
Reference in New Issue
Block a user