blind fix for wxMotif compilation with wxHAVE_LIB_XPM == 0

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20342 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-04-25 11:10:45 +00:00
parent c5a2f27478
commit 0cad49b42c

View File

@@ -1134,11 +1134,11 @@ bool wxGetImageFromDrawable(GR_DRAW_ID drawable, int srcX, int srcY, int width,
GrGetScreenInfo(&sinfo);
if (sinfo.pixtype == MWPF_PALETTE) {
if(!(palette = (GR_PALETTE*) malloc(sizeof(GR_PALETTE)))) {
return FALSE;
}
GrGetSystemPalette(palette);
}
if(!(palette = (GR_PALETTE*) malloc(sizeof(GR_PALETTE)))) {
return FALSE;
}
GrGetSystemPalette(palette);
}
if(!(pixels = (GR_PIXELVAL*) malloc(sizeof(GR_PIXELVAL) * width * height)))
{
@@ -1147,55 +1147,55 @@ bool wxGetImageFromDrawable(GR_DRAW_ID drawable, int srcX, int srcY, int width,
image.Create(width, height);
GrReadArea(drawable, srcX, srcY, width, height,
pixels);
GrReadArea(drawable, srcX, srcY, width, height,
pixels);
for(x = 0; x < sinfo.cols; x++) {
for(x = 0; x < sinfo.cols; x++) {
pp = (unsigned char *)pixels +
((x + (y * sinfo.cols)) *
sizeof(GR_PIXELVAL));
pp = (unsigned char *)pixels +
((x + (y * sinfo.cols)) *
sizeof(GR_PIXELVAL));
switch(sinfo.pixtype) {
/* FIXME: These may need modifying on big endian. */
case MWPF_TRUECOLOR0888:
case MWPF_TRUECOLOR888:
rgb[0] = pp[2];
rgb[1] = pp[1];
rgb[2] = pp[0];
break;
case MWPF_PALETTE:
rgb[0] = palette->palette[pp[0]].r;
rgb[1] = palette->palette[pp[0]].g;
rgb[2] = palette->palette[pp[0]].b;
break;
case MWPF_TRUECOLOR565:
rgb[0] = pp[1] & 0xf8;
rgb[1] = ((pp[1] & 0x07) << 5) |
((pp[0] & 0xe0) >> 3);
rgb[2] = (pp[0] & 0x1f) << 3;
break;
case MWPF_TRUECOLOR555:
rgb[0] = (pp[1] & 0x7c) << 1;
rgb[1] = ((pp[1] & 0x03) << 6) |
((pp[0] & 0xe0) >> 2);
rgb[2] = (pp[0] & 0x1f) << 3;
break;
case MWPF_TRUECOLOR332:
rgb[0] = pp[0] & 0xe0;
rgb[1] = (pp[0] & 0x1c) << 3;
rgb[2] = (pp[0] & 0x03) << 6;
break;
default:
fprintf(stderr, "Unsupported pixel "
"format\n");
return 1;
}
switch(sinfo.pixtype) {
/* FIXME: These may need modifying on big endian. */
case MWPF_TRUECOLOR0888:
case MWPF_TRUECOLOR888:
rgb[0] = pp[2];
rgb[1] = pp[1];
rgb[2] = pp[0];
break;
case MWPF_PALETTE:
rgb[0] = palette->palette[pp[0]].r;
rgb[1] = palette->palette[pp[0]].g;
rgb[2] = palette->palette[pp[0]].b;
break;
case MWPF_TRUECOLOR565:
rgb[0] = pp[1] & 0xf8;
rgb[1] = ((pp[1] & 0x07) << 5) |
((pp[0] & 0xe0) >> 3);
rgb[2] = (pp[0] & 0x1f) << 3;
break;
case MWPF_TRUECOLOR555:
rgb[0] = (pp[1] & 0x7c) << 1;
rgb[1] = ((pp[1] & 0x03) << 6) |
((pp[0] & 0xe0) >> 2);
rgb[2] = (pp[0] & 0x1f) << 3;
break;
case MWPF_TRUECOLOR332:
rgb[0] = pp[0] & 0xe0;
rgb[1] = (pp[0] & 0x1c) << 3;
rgb[2] = (pp[0] & 0x03) << 6;
break;
default:
fprintf(stderr, "Unsupported pixel "
"format\n");
return 1;
}
image.SetRGB(x, y, rgb[0], rgb[1], rgb[2]);
image.SetRGB(x, y, rgb[0], rgb[1], rgb[2]);
}
}
free(pixels);
if(palette) free(palette);
@@ -1207,45 +1207,45 @@ bool wxGetImageFromDrawable(GR_DRAW_ID drawable, int srcX, int srcY, int width,
int GrGetPixelColor(GR_SCREEN_INFO* sinfo, GR_PALETTE* palette, GR_PIXELVAL pixel,
unsigned char* red, unsigned char* green, unsigned char* blue)
{
unsigned char rgb[3], *pp;
unsigned char rgb[3], *pp;
pp = (unsigned char*) & pixel ;
switch (sinfo.pixtype)
{
/* FIXME: These may need modifying on big endian. */
case MWPF_TRUECOLOR0888:
case MWPF_TRUECOLOR888:
rgb[0] = pp[2];
rgb[1] = pp[1];
rgb[2] = pp[0];
break;
case MWPF_PALETTE:
rgb[0] = palette->palette[pp[0]].r;
rgb[1] = palette->palette[pp[0]].g;
rgb[2] = palette->palette[pp[0]].b;
break;
case MWPF_TRUECOLOR565:
rgb[0] = pp[1] & 0xf8;
rgb[1] = ((pp[1] & 0x07) << 5) |
((pp[0] & 0xe0) >> 3);
rgb[2] = (pp[0] & 0x1f) << 3;
break;
case MWPF_TRUECOLOR555:
rgb[0] = (pp[1] & 0x7c) << 1;
rgb[1] = ((pp[1] & 0x03) << 6) |
((pp[0] & 0xe0) >> 2);
rgb[2] = (pp[0] & 0x1f) << 3;
break;
case MWPF_TRUECOLOR332:
rgb[0] = pp[0] & 0xe0;
rgb[1] = (pp[0] & 0x1c) << 3;
rgb[2] = (pp[0] & 0x03) << 6;
break;
default:
fprintf(stderr, "Unsupported pixel format\n");
return 0;
}
/* FIXME: These may need modifying on big endian. */
case MWPF_TRUECOLOR0888:
case MWPF_TRUECOLOR888:
rgb[0] = pp[2];
rgb[1] = pp[1];
rgb[2] = pp[0];
break;
case MWPF_PALETTE:
rgb[0] = palette->palette[pp[0]].r;
rgb[1] = palette->palette[pp[0]].g;
rgb[2] = palette->palette[pp[0]].b;
break;
case MWPF_TRUECOLOR565:
rgb[0] = pp[1] & 0xf8;
rgb[1] = ((pp[1] & 0x07) << 5) |
((pp[0] & 0xe0) >> 3);
rgb[2] = (pp[0] & 0x1f) << 3;
break;
case MWPF_TRUECOLOR555:
rgb[0] = (pp[1] & 0x7c) << 1;
rgb[1] = ((pp[1] & 0x03) << 6) |
((pp[0] & 0xe0) >> 2);
rgb[2] = (pp[0] & 0x1f) << 3;
break;
case MWPF_TRUECOLOR332:
rgb[0] = pp[0] & 0xe0;
rgb[1] = (pp[0] & 0x1c) << 3;
rgb[2] = (pp[0] & 0x03) << 6;
break;
default:
fprintf(stderr, "Unsupported pixel format\n");
return 0;
}
*(red) = rgb[0];
@@ -1357,13 +1357,10 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name,
if (stream.Ok())
{
wxImage image(decoder.ReadFile(stream));
if (image.Ok())
return CreateFromImage(image);
else
return FALSE;
return image.Ok() && bitmap->CreateFromImage(image);
}
else
return FALSE;
#else // !wxHAVE_LIB_XPM && !wxUSE_STREAMS
return FALSE;
#endif // wxHAVE_LIB_XPM / wxUSE_STREAMS
}
@@ -1463,7 +1460,7 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *bits,
M_BMPHANDLERDATA->m_mask->SetBitmap( (WXPixmap) mask );
M_BMPHANDLERDATA->m_mask->SetDisplay( xdisplay );
}
return TRUE;
return TRUE;
}
else
{
@@ -1471,14 +1468,11 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *bits,
return FALSE;
}
#else
#else // !wxHAVE_LIB_XPM
wxXPMDecoder decoder;
wxImage image(decoder.ReadData(bits));
if (image.Ok())
return bitmap->CreateFromImage(image);
else
return FALSE;
#endif
wxImage image(decoder.ReadData((const char **)bits));
return image.Ok() && bitmap->CreateFromImage(image);
#endif // wxHAVE_LIB_XPM/!wxHAVE_LIB_XPM
}
#endif // wxUSE_XPM