]> git.saurik.com Git - wxWidgets.git/commitdiff
forbid modifying wxImage by assigning to wxImagePixelData::Iterator::Data(), this...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 23 Jul 2008 23:26:28 +0000 (23:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 23 Jul 2008 23:26:28 +0000 (23:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/rawbmp.h

index dd0485d8a86296664b969cefdf5739aa22533704..d636d586e5b86750605f05f58ba9b6d6e7a82dfd 100644 (file)
@@ -413,7 +413,11 @@ struct wxPixelDataOut<wxImage>
             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<wxBitmap>
             // 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; }