X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c96ea65713a8dd58ae40b10718723b5c92a303e3..c43430bbacbf26414693fcf47fe54a8090c6bfcb:/src/common/imagpcx.cpp?ds=sidebyside diff --git a/src/common/imagpcx.cpp b/src/common/imagpcx.cpp index d03735e4c5..17a9b54bd5 100644 --- a/src/common/imagpcx.cpp +++ b/src/common/imagpcx.cpp @@ -102,7 +102,7 @@ void RLEdecode(unsigned char *p, unsigned int size, wxInputStream& s) // if ((data & 0xC0) != 0xC0) { - *(p++) = data; + *(p++) = (unsigned char)data; size--; } else @@ -110,7 +110,7 @@ void RLEdecode(unsigned char *p, unsigned int size, wxInputStream& s) cont = data & 0x3F; data = (unsigned char)s.GetC(); for (i = 1; i <= cont; i++) - *(p++) = data; + *(p++) = (unsigned char)data; size -= cont; } } @@ -277,9 +277,10 @@ int ReadPCX(wxImage *image, wxInputStream& stream) *(p++) = pal[3 * index + 2]; } - unsigned char* r = new unsigned char[256]; - unsigned char* g = new unsigned char[256]; - unsigned char* b = new unsigned char[256]; +#if wxUSE_PALETTE + unsigned char r[256]; + unsigned char g[256]; + unsigned char b[256]; for (i = 0; i < 256; i++) { r[i] = pal[3*i + 0]; @@ -287,7 +288,7 @@ int ReadPCX(wxImage *image, wxInputStream& stream) b[i] = pal[3*i + 2]; } image->SetPalette(wxPalette(256, r, g, b)); - delete[] r; delete[] g; delete[] b; +#endif // wxUSE_PALETTE } return wxPCX_OK; @@ -349,12 +350,12 @@ int SavePCX(wxImage *image, wxOutputStream& stream) hdr[HDR_ENCODING] = 1; hdr[HDR_NPLANES] = nplanes; hdr[HDR_BITSPERPIXEL] = 8; - hdr[HDR_BYTESPERLINE] = bytesperline % 256; - hdr[HDR_BYTESPERLINE + 1] = bytesperline / 256; - hdr[HDR_XMAX] = (width - 1) % 256; - hdr[HDR_XMAX + 1] = (width - 1) / 256; - hdr[HDR_YMAX] = (height - 1) % 256; - hdr[HDR_YMAX + 1] = (height - 1) / 256; + hdr[HDR_BYTESPERLINE] = (unsigned char)(bytesperline % 256); + hdr[HDR_BYTESPERLINE + 1] = (unsigned char)(bytesperline / 256); + hdr[HDR_XMAX] = (unsigned char)((width - 1) % 256); + hdr[HDR_XMAX + 1] = (unsigned char)((width - 1) / 256); + hdr[HDR_YMAX] = (unsigned char)((height - 1) % 256); + hdr[HDR_YMAX + 1] = (unsigned char)((height - 1) / 256); hdr[HDR_PALETTEINFO] = 1; stream.Write(hdr, 128);