diff --git a/Minecraft.Client/ScreenshotManager.cpp b/Minecraft.Client/ScreenshotManager.cpp index 802c8b6dd..781549079 100644 --- a/Minecraft.Client/ScreenshotManager.cpp +++ b/Minecraft.Client/ScreenshotManager.cpp @@ -130,12 +130,12 @@ bool ScreenshotManager::takeScreenshot(const std::wstring& path) { GUID wicFormat = GUID_WICPixelFormat32bppBGRA; - // we swizzle R / B because WIC expects BGRA for some fucking reason const UINT width = desc.Width; const UINT height = desc.Height; const UINT srcRowPitch = mapped.RowPitch; const UINT dstStride = width * 4; + // write data and shi std::vector imageData(dstStride * height); BYTE* dst = imageData.data(); BYTE* srcBase = reinterpret_cast(mapped.pData); @@ -143,14 +143,23 @@ bool ScreenshotManager::takeScreenshot(const std::wstring& path) { BYTE* src = srcBase + y * srcRowPitch; BYTE* row = dst + y * dstStride; for (UINT x = 0; x < width; ++x) { + // read original rgba BYTE r = src[x * 4 + 0]; BYTE g = src[x * 4 + 1]; BYTE b = src[x * 4 + 2]; BYTE a = src[x * 4 + 3]; - row[x * 4 + 0] = b; - row[x * 4 + 1] = g; - row[x * 4 + 2] = r; - row[x * 4 + 3] = a; + + // black background to fix opacity issues (sorta) + // (using integer math with rounding: (value * a + 127) / 255) + UINT br = (r * a + 127) / 255; + UINT bg = (g * a + 127) / 255; + UINT bb = (b * a + 127) / 255; + + // we swizzle R / B because WIC expects BGRA for some fucking reason + row[x * 4 + 0] = static_cast(bb); + row[x * 4 + 1] = static_cast(bg); + row[x * 4 + 2] = static_cast(br); + row[x * 4 + 3] = 255; } }