From acbf1bce14c9bd43887100266254759cd354cc48 Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 6 Jun 2024 16:52:45 +0300 Subject: [PATCH] Fixed bit depth stuff (is it always BGRA??) --- img/scrall/screenshot.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/img/scrall/screenshot.c b/img/scrall/screenshot.c index 93eefc4..8e9a95a 100644 --- a/img/scrall/screenshot.c +++ b/img/scrall/screenshot.c @@ -47,20 +47,11 @@ Image get_screenshot(xcb_connection_t *conn, xcb_window_t wid) { Image img = GenImageColor(win_w, win_h, BLANK); - if (win_d == 24) { - for (int i = 0; i < data_len / 3; i++) { - ((uint8_t *)img.data)[i * 4 + 0] = data[i * 3 + 2]; - ((uint8_t *)img.data)[i * 4 + 1] = data[i * 3 + 1]; - ((uint8_t *)img.data)[i * 4 + 2] = data[i * 3 + 0]; - ((uint8_t *)img.data)[i * 4 + 3] = 0xff; - } - } else { - for (int i = 0; i < data_len / 4; i++) { - ((uint8_t *)img.data)[i * 4 + 0] = data[i * 4 + 2]; - ((uint8_t *)img.data)[i * 4 + 1] = data[i * 4 + 1]; - ((uint8_t *)img.data)[i * 4 + 2] = data[i * 4 + 0]; - ((uint8_t *)img.data)[i * 4 + 3] = data[i * 4 + 3]; - } + for (int i = 0; i < data_len; i += 4) { + ((uint8_t *)img.data)[i + 0] = data[i + 2]; + ((uint8_t *)img.data)[i + 1] = data[i + 1]; + ((uint8_t *)img.data)[i + 2] = data[i + 0]; + ((uint8_t *)img.data)[i + 3] = win_d == 24 ? 0xff : data[i + 3]; } free(gi_reply);