From 4bee5a27340c23764ebc43d8f8fbf990c8a62b01 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 20 Apr 2017 22:31:00 +0200 Subject: invert partial fix --- op.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/op.c b/op.c index 6273541..c208ff7 100644 --- a/op.c +++ b/op.c @@ -87,20 +87,24 @@ op_invert(struct ida_image *src, struct ida_rect *rect, unsigned char *dst, int line, void *data) { unsigned char *scanline; - int i; + int i, bpp; + bpp = ida_image_bpp(src); scanline = ida_image_scanline(src, line); - memcpy(dst,scanline,src->i.width * 3); + memcpy(dst, scanline, ida_image_stride(src)); if (line < rect->y1 || line >= rect->y2) return; - dst += 3*rect->x1; - scanline += 3*rect->x1; + dst += bpp*rect->x1; + scanline += bpp*rect->x1; for (i = rect->x1; i < rect->x2; i++) { + + /* FIXME for bpp != 3 */ dst[0] = 255-scanline[0]; dst[1] = 255-scanline[1]; dst[2] = 255-scanline[2]; - scanline += 3; - dst += 3; + + scanline += bpp; + dst += bpp; } } -- cgit