Module: wine Branch: master Commit: b8c38f418699bf71896de5f5cbbd6dd07082b390 URL: https://gitlab.winehq.org/wine/wine/-/commit/b8c38f418699bf71896de5f5cbbd6dd...
Author: Ilia Docin ilya.docin@contentai.ru Date: Sun Aug 6 14:25:23 2023 +0300
sane.ds: Use BGR order to store 24 bit color DIB pixels.
---
dlls/sane.ds/ds_image.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/sane.ds/ds_image.c b/dlls/sane.ds/ds_image.c index 93193abc69f..2c52184a056 100644 --- a/dlls/sane.ds/ds_image.c +++ b/dlls/sane.ds/ds_image.c @@ -301,10 +301,11 @@ TW_UINT16 SANE_ImageNativeXferGet (pTW_IDENTITY pOrigin, BITMAPINFOHEADER *header = NULL; int dib_bytes; int dib_bytes_per_line; - BYTE *line; + BYTE *line, color_buffer; RGBQUAD *colors; + RGBTRIPLE *pixels; int color_size = 0; - int i; + int i, j; BYTE *p;
TRACE("DG_IMAGE/DAT_IMAGENATIVEXFER/MSG_GET\n"); @@ -425,6 +426,17 @@ TW_UINT16 SANE_ImageNativeXferGet (pTW_IDENTITY pOrigin, twRC = SANE_CALL( read_data, ¶ms ); if (twRC != TWCC_SUCCESS) break; if (retlen < activeDS.frame_params.bytes_per_line) break; + /* TWAIN: for 24 bit color DIBs, the pixels are stored in BGR order */ + if (activeDS.frame_params.format == FMT_RGB && activeDS.frame_params.depth == 8) + { + pixels = (RGBTRIPLE *) line; + for (j = 0; j < activeDS.frame_params.pixels_per_line; ++j) + { + color_buffer = pixels[j].rgbtRed; + pixels[j].rgbtRed = pixels[j].rgbtBlue; + pixels[j].rgbtBlue = color_buffer; + } + } line -= dib_bytes_per_line; } activeDS.progressWnd = ScanningDialogBox(activeDS.progressWnd, -1);