mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 11:24:27 +01:00
GE Debugger: Copy images optionally with alpha.
Although, lots of apps don't support this.
This commit is contained in:
1 parent
f3722faef4
commit
3cc628beb4
8 files changed
+158
-45
No files matched your search
+28
-2
@@ -406,8 +406,7 @@ bool Save888RGBScreenshot(const Path &filename, ScreenshotFormat fmt, const u8 *
|
||||
}
|
||||
|
||||
bool Save8888RGBAScreenshot(const Path &filename, const u8 *buffer, int w, int h) {
|
||||
png_image png;
|
||||
memset(&png, 0, sizeof(png));
|
||||
png_image png{};
|
||||
png.version = PNG_IMAGE_VERSION;
|
||||
png.format = PNG_FORMAT_RGBA;
|
||||
png.width = w;
|
||||
@@ -421,3 +420,30 @@ bool Save8888RGBAScreenshot(const Path &filename, const u8 *buffer, int w, int h
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Save8888RGBAScreenshot(std::vector<uint8_t> &bufferPNG, const u8 *bufferRGBA8888, int w, int h) {
|
||||
png_image png{};
|
||||
png.version = PNG_IMAGE_VERSION;
|
||||
png.format = PNG_FORMAT_RGBA;
|
||||
png.width = w;
|
||||
png.height = h;
|
||||
|
||||
png_alloc_size_t allocSize = bufferPNG.size();
|
||||
int result = png_image_write_to_memory(&png, allocSize == 0 ? nullptr : bufferPNG.data(), &allocSize, 0, bufferRGBA8888, w * 4, nullptr);
|
||||
bool success = result != 0 && png.warning_or_error <= 1;
|
||||
if (!success && allocSize != bufferPNG.size()) {
|
||||
bufferPNG.resize(allocSize);
|
||||
png.warning_or_error = 0;
|
||||
result = png_image_write_to_memory(&png, bufferPNG.data(), &allocSize, 0, bufferRGBA8888, w * 4, nullptr);
|
||||
success = result != 0 && png.warning_or_error <= 1;
|
||||
}
|
||||
if (success)
|
||||
bufferPNG.resize(allocSize);
|
||||
png_image_free(&png);
|
||||
|
||||
if (!success) {
|
||||
ERROR_LOG(IO, "Buffering screenshot to PNG produced errors.");
|
||||
bufferPNG.clear();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
Reference in new issue
Block a user