OpenGL Renderer: Pad the line pitch to the nearest dword when taking non-raw screenshots, fixed messed up screenshots.

This commit is contained in:
OBattler
2026-02-13 11:27:33 +01:00
parent 283d9b4fcc
commit 42c5c2a73f

View File

@@ -1726,7 +1726,8 @@ OpenGLRenderer::render()
glw.glFinish();
glw.glReadPixels(window_rect.x, window_rect.y, width, height, GL_RGB, GL_UNSIGNED_BYTE, rgb);
QImage image((uchar*)rgb, width, height, width * 3, QImage::Format_RGB888);
int pitch_adj = (4 - ((width * 3) & 3)) & 3;
QImage image((uchar*)rgb, width, height, (width * 3) + pitch_adj, QImage::Format_RGB888);
image.mirrored(false, true).save(path, "png");
monitors[r_monitor_index].mon_screenshots--;
free(rgb);
@@ -1739,7 +1740,8 @@ OpenGLRenderer::render()
glw.glFinish();
glw.glReadPixels(window_rect.x, window_rect.y, width, height, GL_RGB, GL_UNSIGNED_BYTE, rgb);
QImage image((uchar*)rgb, width, height, width * 3, QImage::Format_RGB888);
int pitch_adj = (4 - ((width * 3) & 3)) & 3;
QImage image((uchar*)rgb, width, height, (width * 3) + pitch_adj, QImage::Format_RGB888);
QClipboard *clipboard = QApplication::clipboard();
clipboard->setImage(image.mirrored(false, true), QClipboard::Clipboard);
monitors[r_monitor_index].mon_screenshots_clipboard--;