Permalink
Browse files

thin3d: Convert BGRA8888 to RGB888 for screenshots.

In case we prefer BGRA for some buffer in Vulkan.  Also reporting.
  • Loading branch information...
unknownbrackets committed Jun 3, 2018
1 parent 7c8780b commit e90b01d9acca4792ecb11f022df023edbb95475b
Showing with 14 additions and 4 deletions.
  1. +14 −4 ext/native/thin3d/thin3d.cpp
@@ -428,12 +428,22 @@ void ConvertFromBGRA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, u
src32 += srcStride;
dst32 += dstStride;
}
}
else {
// Don't even bother with these, this path only happens in screenshots and we don't save those to 16-bit.
assert(false);
} else if (format == Draw::DataFormat::R8G8B8_UNORM) {
for (uint32_t y = 0; y < height; ++y) {
for (uint32_t x = 0; x < width; ++x) {
uint32_t c = src32[x];
dst[x * 3 + 0] = (c >> 16) & 0xFF;
dst[x * 3 + 1] = (c >> 8) & 0xFF;
dst[x * 3 + 2] = (c >> 0) & 0xFF;
}
src32 += srcStride;
dst += dstStride * 3;
}
} else {
WARN_LOG_REPORT_ONCE(convFromBGRA, G3D, "Unable to convert from format to BGRA: %d", (int)format);
}
}
void ConvertToD32F(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format) {
if (format == Draw::DataFormat::D32F) {
const float *src32 = (const float *)src;

0 comments on commit e90b01d

Please sign in to comment.