From b670bf98e0340ce9407c30a03fe85af3af09e81b Mon Sep 17 00:00:00 2001 From: Mike Dussault Date: Wed, 15 Sep 2021 10:13:02 -0700 Subject: [PATCH] Fixed a bug in Image::Buffer that would return the wrong location in the image if the image had > 1 channels (and if the request were for x > 0). --- src/zm_image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_image.h b/src/zm_image.h index 2a3c68232..0665caade 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -180,7 +180,7 @@ class Image { /* Internal buffer should not be modified from functions outside of this class */ inline const uint8_t* Buffer() const { return buffer; } - inline const uint8_t* Buffer(unsigned int x, unsigned int y=0) const { return &buffer[(y*linesize)+x]; } + inline const uint8_t* Buffer(unsigned int x, unsigned int y=0) const { return &buffer[(y*linesize) + x*colours]; } /* Request writeable buffer */ uint8_t* WriteBuffer(const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder); // Is only acceptable on a pre-allocated buffer