#pragma hdrstop
#endif
+#include "wx/defs.h"
+
+#if wxUSE_IMAGE
+
#include "wx/imagbmp.h"
#include "wx/bitmap.h"
#include "wx/debug.h"
*/
if (bpp < 16 && ncolors != 0)
{
+ unsigned char* r = new unsigned char[ncolors];
+ unsigned char* g = new unsigned char[ncolors];
+ unsigned char* b = new unsigned char[ncolors];
for (int j = 0; j < ncolors; j++)
{
stream.Read( bbuf, 4 );
cmap[j].b = bbuf[0];
cmap[j].g = bbuf[1];
cmap[j].r = bbuf[2];
+
+ r[j] = cmap[j].r;
+ g[j] = cmap[j].g;
+ b[j] = cmap[j].b;
}
+ // Set the palette for the wxImage
+ image->SetPalette(wxPalette(ncolors, r, g, b));
+
+ delete[] r;
+ delete[] g;
+ delete[] b;
}
else if (bpp == 16 || bpp == 32)
{
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;
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)
}
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;
#endif // wxUSE_STREAMS
-
+#endif // wxUSE_IMAGE