From 9f4aef4053c739a5e81a3a6183c7f4c7d573c9f5 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 15 May 2025 19:22:06 +0100 Subject: [PATCH] Image::BitmapData: Update getters to allow for negative lineStride --- modules/juce_graphics/images/juce_Image.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/juce_graphics/images/juce_Image.h b/modules/juce_graphics/images/juce_Image.h index 6686380ce8..eada8c900c 100644 --- a/modules/juce_graphics/images/juce_Image.h +++ b/modules/juce_graphics/images/juce_Image.h @@ -343,13 +343,19 @@ public: The coordinate you provide here isn't checked, so it's the caller's responsibility to make sure it's not out-of-range. */ - inline uint8* getLinePointer (int y) const noexcept { return data + (size_t) y * (size_t) lineStride; } + inline uint8* getLinePointer (int y) const noexcept + { + return data + (ptrdiff_t) y * (ptrdiff_t) lineStride; + } /** Returns a pointer to a pixel in the image. The coordinates you give here are not checked, so it's the caller's responsibility to make sure they're not out-of-range. */ - inline uint8* getPixelPointer (int x, int y) const noexcept { return data + (size_t) y * (size_t) lineStride + (size_t) x * (size_t) pixelStride; } + inline uint8* getPixelPointer (int x, int y) const noexcept + { + return data + (ptrdiff_t) y * (ptrdiff_t) lineStride + (ptrdiff_t) x * (ptrdiff_t) pixelStride; + } /** Returns the colour of a given pixel. For performance reasons, this won't do any bounds-checking on the coordinates, so it's the caller's