From 4800a07000d9d830c67a662cf2cdc00980808f0d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 23 Jul 2008 23:26:28 +0000 Subject: [PATCH] forbid modifying wxImage by assigning to wxImagePixelData::Iterator::Data(), this doesn't work correctly git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/rawbmp.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/wx/rawbmp.h b/include/wx/rawbmp.h index dd0485d8a8..d636d586e5 100644 --- a/include/wx/rawbmp.h +++ b/include/wx/rawbmp.h @@ -413,7 +413,11 @@ struct wxPixelDataOut ChannelType& Alpha() { return *m_pAlpha; } // address the pixel contents directly (always RGB, without alpha) - typename PixelFormat::PixelType& Data() + // + // this can't be used to modify the image as assigning a 32bpp + // value to 24bpp pixel would overwrite an extra byte in the next + // pixel or beyond the end of image + const typename PixelFormat::PixelType& Data() { return *(typename PixelFormat::PixelType *)m_pRGB; } // private: -- see comment in the beginning of the file @@ -600,6 +604,10 @@ struct wxPixelDataOut // address the pixel contents directly // // warning: the format is platform dependent + // + // warning 2: assigning to Data() only works correctly for 16bpp or + // 32bpp formats but using it for 24bpp ones overwrites + // one extra byte and so can't be done typename PixelFormat::PixelType& Data() { return *(typename PixelFormat::PixelType *)m_ptr; } -- 2.45.2