From efd2f8a1a863f0369ac2efb7c3686502dfa33a48 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 14 Jan 2020 12:14:03 +0200 Subject: [PATCH] - implemented screenshots in softpoly backend --- .../polyrenderer/backend/poly_framebuffer.cpp | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/rendering/polyrenderer/backend/poly_framebuffer.cpp b/src/rendering/polyrenderer/backend/poly_framebuffer.cpp index 6165eb77f..00901fe37 100644 --- a/src/rendering/polyrenderer/backend/poly_framebuffer.cpp +++ b/src/rendering/polyrenderer/backend/poly_framebuffer.cpp @@ -560,15 +560,24 @@ TArray PolyFrameBuffer::GetScreenshotBuffer(int &pitch, ESSType &color_ int w = SCREENWIDTH; int h = SCREENHEIGHT; - IntRect box; - box.left = 0; - box.top = 0; - box.width = w; - box.height = h; - //mPostprocess->DrawPresentTexture(box, true, true); - TArray ScreenshotBuffer(w * h * 3, true); - //CopyScreenToBuffer(w, h, ScreenshotBuffer.Data()); + const uint8_t* pixels = GetCanvas()->GetPixels(); + int dindex = 0; + + // Convert to RGB + for (int y = 0; y < h; y++) + { + int sindex = y * w * 4; + + for (int x = 0; x < w; x++) + { + ScreenshotBuffer[dindex ] = pixels[sindex + 2]; + ScreenshotBuffer[dindex + 1] = pixels[sindex + 1]; + ScreenshotBuffer[dindex + 2] = pixels[sindex ]; + dindex += 3; + sindex += 4; + } + } pitch = w * 3; color_type = SS_RGB;