]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/imagbmp.cpp
added xpmdecod.cpp
[wxWidgets.git] / src / common / imagbmp.cpp
index 5819bd7ec69ce66f0e50b464405fff80d56a030d..9f92b3c8fc6505d6e8ea22194c6c6d8308af6529 100644 (file)
 #pragma hdrstop
 #endif
 
+#include "wx/defs.h"
+
+#if wxUSE_IMAGE
+
 #include "wx/imagbmp.h"
 #include "wx/bitmap.h"
 #include "wx/debug.h"
@@ -383,7 +387,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
                 if (bpp == 1)
                 {
                     int bit = 0;
-                    for (bit = 0; bit < 8; bit++)
+                    for (bit = 0; bit < 8 && column < width; bit++)
                     {
                         index = ((aByte & (0x80 >> bit)) ? 1 : 0);
                         ptr[poffset] = cmap[index].r;
@@ -405,7 +409,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
                     else
                     {
                         int nibble = 0;
-                        for (nibble = 0; nibble < 2; nibble++)
+                        for (nibble = 0; nibble < 2 && column < width; nibble++)
                         {
                             index = ((aByte & (0xF0 >> nibble * 4)) >> (!nibble * 4));
                             if (index >= 16)
@@ -461,7 +465,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
                         }
                         else
                         {
-                            for (int l = 0; l < first; l++)
+                            for (int l = 0; l < first && column < width; l++)
                             {
                                 ptr[poffset    ] = cmap[aByte].r;
                                 ptr[poffset + 1] = cmap[aByte].g;
@@ -546,4 +550,4 @@ bool wxBMPHandler::DoCanRead( wxInputStream& stream )
 
 #endif // wxUSE_STREAMS
 
-
+#endif // wxUSE_IMAGE