Fixed bit depth stuff (is it always BGRA??)

This commit is contained in:
Casey 2024-06-06 16:52:45 +03:00
parent f921c61b23
commit acbf1bce14
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 5 additions and 14 deletions

View File

@ -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);