Patch level :2.1 042

Files correlati     :xvagadll.dll
Ricompilazione Demo : [ ]
Commento            :corretta la get_ncolors scrivendo <256 e non <255 colori; senza questa
correzione il 256-esimo colore della palette di una immagine veniva ignorata (e per pura sfiga,
nel logo one-red, era il bianco!)


git-svn-id: svn://10.65.10.50/trunk@12073 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2004-05-13 15:07:36 +00:00
parent 4dafef59bf
commit e007d5e048

View File

@ -2822,7 +2822,6 @@ void xvt_image_destroy(XVT_IMAGE image)
COLOR xvt_image_get_clut(XVT_IMAGE image, short index) COLOR xvt_image_get_clut(XVT_IMAGE image, short index)
{ {
XVT_ASSERT(image != NULL); XVT_ASSERT(image != NULL);
#if wxCHECK_VERSION(2,3,0)
if (image) if (image)
{ {
const wxImage& bmp = ((const TXVT_IMAGE*)image)->Image(); const wxImage& bmp = ((const TXVT_IMAGE*)image)->Image();
@ -2834,7 +2833,6 @@ COLOR xvt_image_get_clut(XVT_IMAGE image, short index)
return MAKE_COLOR(r, g, b); return MAKE_COLOR(r, g, b);
} }
} }
#endif
return COLOR_BLACK; return COLOR_BLACK;
} }
@ -2856,17 +2854,12 @@ void xvt_image_get_dimensions(XVT_IMAGE image, short *width, short *height)
XVT_IMAGE_FORMAT xvt_image_get_format(XVT_IMAGE image) XVT_IMAGE_FORMAT xvt_image_get_format(XVT_IMAGE image)
{ {
#if wxCHECK_VERSION(2,3,0)
const wxImage& img = ((const TXVT_IMAGE*)image)->Image(); const wxImage& img = ((const TXVT_IMAGE*)image)->Image();
return img.HasPalette() ? XVT_IMAGE_CL8 : XVT_IMAGE_RGB; return img.HasPalette() ? XVT_IMAGE_CL8 : XVT_IMAGE_RGB;
#else
return XVT_IMAGE_RGB;
#endif
} }
short xvt_image_get_ncolors(XVT_IMAGE image) short xvt_image_get_ncolors(XVT_IMAGE image)
{ {
#if wxCHECK_VERSION(2,3,0)
int n = 0; int n = 0;
if (image) if (image)
{ {
@ -2875,7 +2868,7 @@ short xvt_image_get_ncolors(XVT_IMAGE image)
{ {
const wxPalette& pal = bmp.GetPalette(); const wxPalette& pal = bmp.GetPalette();
unsigned char r, g, b; unsigned char r, g, b;
for (n = 16; n < 255; n++) for (n = 16; n < 256; n++)
{ {
if (!pal.GetRGB(n, &r, &g, &b)) if (!pal.GetRGB(n, &r, &g, &b))
break; break;
@ -2883,15 +2876,6 @@ short xvt_image_get_ncolors(XVT_IMAGE image)
} }
} }
return n; return n;
#else
int n = 0;
if (image)
{
wxImage& bmp = ((TXVT_IMAGE*)image)->Image();
n = bmp.CountColours(257);
}
return n > 256 ? 0 : n;
#endif
} }
COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y) COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y)
@ -2941,7 +2925,6 @@ XVT_IMAGE xvt_image_read_bmp(const char *filenamep)
void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color) void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color)
{ {
wxImage& bmp = ((TXVT_IMAGE*)image)->Image(); wxImage& bmp = ((TXVT_IMAGE*)image)->Image();
#if wxCHECK_VERSION(2,3,0)
if (bmp.HasPalette()) if (bmp.HasPalette())
{ {
const wxPalette& pal = bmp.GetPalette(); const wxPalette& pal = bmp.GetPalette();
@ -2962,7 +2945,6 @@ void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color)
bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue()); bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue());
} }
} }
#endif
} }
void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors) void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors)