Fix the "64 colors flx too dark" bug.

Original commit message from CVS:
Fix the "64 colors flx too dark" bug.
This commit is contained in:
Wim Taymans 2002-01-18 18:41:58 +00:00
parent 5c28518728
commit f34f00f438
3 changed files with 32 additions and 15 deletions

View file

@ -66,7 +66,7 @@ flx_colorspace_convert(FlxColorSpaceConverter *flxpal, guchar *src, guchar *dest
void
flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num, guchar *newpal)
flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num, guchar *newpal, gint scale)
{
guint grab;
@ -75,20 +75,33 @@ flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num, g
grab = ((start + num) > 0x100 ? 0x100 - start : num);
if (scale) {
gint i = 0;
start *= 3;
while (grab) {
flxpal->palvec[start++] = newpal[i++] << scale;
flxpal->palvec[start++] = newpal[i++] << scale;
flxpal->palvec[start++] = newpal[i++] << scale;
grab--;
}
}
else {
memcpy(&flxpal->palvec[start * 3], newpal, grab * 3);
}
}
void
flx_set_color(FlxColorSpaceConverter *flxpal, guint colr, guint red, guint green, guint blue)
flx_set_color(FlxColorSpaceConverter *flxpal, guint colr, guint red, guint green, guint blue, gint scale)
{
g_return_if_fail(flxpal != NULL);
g_return_if_fail(colr < 0x100);
flxpal->palvec[(colr * 3)] = red;
flxpal->palvec[(colr * 3) + 1] = green;
flxpal->palvec[(colr * 3) + 2] = blue;
flxpal->palvec[(colr * 3)] = red << scale;
flxpal->palvec[(colr * 3) + 1] = green << scale;
flxpal->palvec[(colr * 3) + 2] = blue << scale;
}

View file

@ -37,7 +37,7 @@ void flx_colorspace_convert(FlxColorSpaceConverter *flxpal, guchar *src, guchar
FlxColorSpaceConverter * flx_colorspace_converter_new(gint width, gint height);
void flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num,
guchar *newpal);
guchar *newpal, gint scale);
void flx_set_color(FlxColorSpaceConverter *flxpal, guint colr, guint red, guint green,
guint blue);
guint blue, gint scale);

View file

@ -98,7 +98,7 @@ static void gst_flxdec_set_property (GObject *object, guint prop_id, const GValu
static void gst_flxdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void flx_decode_color(GstFlxDec *, guchar *, guchar *);
static void flx_decode_color (GstFlxDec *, guchar *, guchar *, gint);
static void flx_decode_brun (GstFlxDec *, guchar *, guchar *);
static void flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
@ -200,8 +200,12 @@ flx_decode_chunks (GstFlxDec *flxdec , gulong count, gchar *data, gchar *dest)
switch(hdr->id)
{
case FLX_COLOR64:
flx_decode_color(flxdec, data, dest, 2);
data += rndalign(hdr->size) - FlxFrameChunkSize;
break;
case FLX_COLOR256:
flx_decode_color(flxdec, data, dest);
flx_decode_color(flxdec, data, dest, 0);
data += rndalign(hdr->size) - FlxFrameChunkSize;
break;
@ -240,7 +244,7 @@ flx_decode_chunks (GstFlxDec *flxdec , gulong count, gchar *data, gchar *dest)
static void
flx_decode_color(GstFlxDec *flxdec, guchar *data, guchar *dest)
flx_decode_color(GstFlxDec *flxdec, guchar *data, guchar *dest, gint scale)
{
guint packs, count, indx;
@ -262,7 +266,7 @@ flx_decode_color(GstFlxDec *flxdec, guchar *data, guchar *dest)
count = 256;
g_print("GstFlxDec: cmap count: %d (indx: %d)\n", count, indx);
flx_set_palette_vector(flxdec->converter, indx, count, data);
flx_set_palette_vector(flxdec->converter, indx, count, data, scale);
data += (count * 3);
}