fixes for wxUSE_PALETTE=0 compilation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11763 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -126,20 +126,23 @@ bool wxGIFDecoder::ConvertToImage(wxImage *image) const
|
|||||||
else
|
else
|
||||||
image->SetMask(FALSE);
|
image->SetMask(FALSE);
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
if (pal)
|
if (pal)
|
||||||
{
|
{
|
||||||
unsigned char* r = new unsigned char[256];
|
unsigned char r[256];
|
||||||
unsigned char* g = new unsigned char[256];
|
unsigned char g[256];
|
||||||
unsigned char* b = new unsigned char[256];
|
unsigned char b[256];
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
r[i] = pal[3*i + 0];
|
r[i] = pal[3*i + 0];
|
||||||
g[i] = pal[3*i + 1];
|
g[i] = pal[3*i + 1];
|
||||||
b[i] = pal[3*i + 2];
|
b[i] = pal[3*i + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
image->SetPalette(wxPalette(256, r, g, b));
|
image->SetPalette(wxPalette(256, r, g, b));
|
||||||
delete[] r; delete[] g; delete[] b;
|
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
/* copy image data */
|
/* copy image data */
|
||||||
for (i = 0; i < (GetWidth() * GetHeight()); i++, src++)
|
for (i = 0; i < (GetWidth() * GetHeight()); i++, src++)
|
||||||
|
@@ -91,7 +91,11 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
(format == wxBMP_8BPP_RED) || (format == wxBMP_8BPP_PALETTE))
|
(format == wxBMP_8BPP_RED) || (format == wxBMP_8BPP_PALETTE))
|
||||||
{
|
{
|
||||||
// need to set a wxPalette to use this, HOW TO CHECK IF VALID, SIZE?
|
// need to set a wxPalette to use this, HOW TO CHECK IF VALID, SIZE?
|
||||||
if ((format == wxBMP_8BPP_PALETTE) && !image->HasPalette())
|
if ((format == wxBMP_8BPP_PALETTE)
|
||||||
|
#if wxUSE_PALETTE
|
||||||
|
&& !image->HasPalette()
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
wxLogError(_("BMP: wImage doesn't have own wxPalette."));
|
wxLogError(_("BMP: wImage doesn't have own wxPalette."));
|
||||||
@@ -196,7 +200,9 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if wxUSE_PALETTE
|
||||||
palette = new wxPalette(image->GetPalette());
|
palette = new wxPalette(image->GetPalette());
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -205,7 +211,10 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
|
|
||||||
for (i=0; i<palette_size; i++)
|
for (i=0; i<palette_size; i++)
|
||||||
{
|
{
|
||||||
if (!palette->GetRGB( i, &r, &g, &b )) r = g = b = 0;
|
#if wxUSE_PALETTE
|
||||||
|
if (!palette->GetRGB( i, &r, &g, &b ))
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
r = g = b = 0;
|
||||||
|
|
||||||
rgbquad[i*4] = b;
|
rgbquad[i*4] = b;
|
||||||
rgbquad[i*4+1] = g;
|
rgbquad[i*4+1] = g;
|
||||||
@@ -236,10 +245,13 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
{
|
{
|
||||||
if (!stream.Write(rgbquad, palette_size*4))
|
if (!stream.Write(rgbquad, palette_size*4))
|
||||||
{
|
{
|
||||||
if (verbose) wxLogError(_("BMP: Couldn't write RGB color map."));
|
if (verbose)
|
||||||
|
wxLogError(_("BMP: Couldn't write RGB color map."));
|
||||||
delete [] rgbquad;
|
delete [] rgbquad;
|
||||||
if (palette) delete palette;
|
#if wxUSE_PALETTE
|
||||||
if (q_image) delete q_image;
|
delete palette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
delete q_image;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
delete []rgbquad;
|
delete []rgbquad;
|
||||||
@@ -273,9 +285,14 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
pixel = 3*(y*width + x);
|
pixel = 3*(y*width + x);
|
||||||
|
#if wxUSE_PALETTE
|
||||||
buffer[x] = palette->GetPixel( data[pixel],
|
buffer[x] = palette->GetPixel( data[pixel],
|
||||||
data[pixel+1],
|
data[pixel+1],
|
||||||
data[pixel+2] );
|
data[pixel+2] );
|
||||||
|
#else
|
||||||
|
// FIXME: what should this be? use some std palette maybe?
|
||||||
|
buffer[x] = 0;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (format == wxBMP_8BPP_GREY) // 1 byte per pix, rgb ave to grey
|
else if (format == wxBMP_8BPP_GREY) // 1 byte per pix, rgb ave to grey
|
||||||
@@ -302,9 +319,20 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
pixel = 3*(y*width + x);
|
pixel = 3*(y*width + x);
|
||||||
|
|
||||||
// fill buffer, ignore if > width
|
// fill buffer, ignore if > width
|
||||||
|
#if wxUSE_PALETTE
|
||||||
buffer[x/2] =
|
buffer[x/2] =
|
||||||
((wxUint8)palette->GetPixel(data[pixel], data[pixel+1], data[pixel+2]) << 4) |
|
((wxUint8)palette->GetPixel(data[pixel],
|
||||||
(((x+1) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+3], data[pixel+4], data[pixel+5]) ));
|
data[pixel+1],
|
||||||
|
data[pixel+2]) << 4) |
|
||||||
|
(((x+1) > width)
|
||||||
|
? 0
|
||||||
|
: ((wxUint8)palette->GetPixel(data[pixel+3],
|
||||||
|
data[pixel+4],
|
||||||
|
data[pixel+5]) ));
|
||||||
|
#else
|
||||||
|
// FIXME: what should this be? use some std palette maybe?
|
||||||
|
buffer[x/2] = 0;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (format == wxBMP_1BPP) // 1 bpp in "color"
|
else if (format == wxBMP_1BPP) // 1 bpp in "color"
|
||||||
@@ -313,8 +341,8 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
{
|
{
|
||||||
pixel = 3*(y*width + x);
|
pixel = 3*(y*width + x);
|
||||||
|
|
||||||
buffer[x/8] =
|
#if wxUSE_PALETTE
|
||||||
((wxUint8)palette->GetPixel(data[pixel], data[pixel+1], data[pixel+2]) << 7) |
|
buffer[x/8] = ((wxUint8)palette->GetPixel(data[pixel], data[pixel+1], data[pixel+2]) << 7) |
|
||||||
(((x+1) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+3], data[pixel+4], data[pixel+5]) << 6)) |
|
(((x+1) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+3], data[pixel+4], data[pixel+5]) << 6)) |
|
||||||
(((x+2) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+6], data[pixel+7], data[pixel+8]) << 5)) |
|
(((x+2) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+6], data[pixel+7], data[pixel+8]) << 5)) |
|
||||||
(((x+3) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+9], data[pixel+10], data[pixel+11]) << 4)) |
|
(((x+3) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+9], data[pixel+10], data[pixel+11]) << 4)) |
|
||||||
@@ -322,6 +350,10 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
(((x+5) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+15], data[pixel+16], data[pixel+17]) << 2)) |
|
(((x+5) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+15], data[pixel+16], data[pixel+17]) << 2)) |
|
||||||
(((x+6) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+18], data[pixel+19], data[pixel+20]) << 1)) |
|
(((x+6) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+18], data[pixel+19], data[pixel+20]) << 1)) |
|
||||||
(((x+7) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+21], data[pixel+22], data[pixel+23]) ));
|
(((x+7) > width) ? 0 : ((wxUint8)palette->GetPixel(data[pixel+21], data[pixel+22], data[pixel+23]) ));
|
||||||
|
#else
|
||||||
|
// FIXME: what should this be? use some std palette maybe?
|
||||||
|
buffer[x/8] = 0;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (format == wxBMP_1BPP_BW) // 1 bpp B&W colormap from red color ONLY
|
else if (format == wxBMP_1BPP_BW) // 1 bpp B&W colormap from red color ONLY
|
||||||
@@ -347,14 +379,18 @@ bool wxBMPHandler::SaveFile(wxImage *image,
|
|||||||
if (verbose)
|
if (verbose)
|
||||||
wxLogError(_("BMP: Couldn't write data."));
|
wxLogError(_("BMP: Couldn't write data."));
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
if (palette) delete palette;
|
#if wxUSE_PALETTE
|
||||||
if (q_image) delete q_image;
|
delete palette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
delete q_image;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
if (palette) delete palette;
|
#if wxUSE_PALETTE
|
||||||
if (q_image) delete q_image;
|
delete palette;
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
delete q_image;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -497,8 +533,11 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
|||||||
g[j] = cmap[j].g;
|
g[j] = cmap[j].g;
|
||||||
b[j] = cmap[j].b;
|
b[j] = cmap[j].b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_PALETTE
|
||||||
// Set the palette for the wxImage
|
// Set the palette for the wxImage
|
||||||
image->SetPalette(wxPalette(ncolors, r, g, b));
|
image->SetPalette(wxPalette(ncolors, r, g, b));
|
||||||
|
#endif // wxUSE_PALETTE
|
||||||
|
|
||||||
delete[] r;
|
delete[] r;
|
||||||
delete[] g;
|
delete[] g;
|
||||||
|
@@ -277,9 +277,10 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
|
|||||||
*(p++) = pal[3 * index + 2];
|
*(p++) = pal[3 * index + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* r = new unsigned char[256];
|
#if wxUSE_PALETTE
|
||||||
unsigned char* g = new unsigned char[256];
|
unsigned char r[256];
|
||||||
unsigned char* b = new unsigned char[256];
|
unsigned char g[256];
|
||||||
|
unsigned char b[256];
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
r[i] = pal[3*i + 0];
|
r[i] = pal[3*i + 0];
|
||||||
@@ -287,7 +288,7 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
|
|||||||
b[i] = pal[3*i + 2];
|
b[i] = pal[3*i + 2];
|
||||||
}
|
}
|
||||||
image->SetPalette(wxPalette(256, r, g, b));
|
image->SetPalette(wxPalette(256, r, g, b));
|
||||||
delete[] r; delete[] g; delete[] b;
|
#endif // wxUSE_PALETTE
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxPCX_OK;
|
return wxPCX_OK;
|
||||||
|
Reference in New Issue
Block a user