Sure, here's an updated patch for git head.
Sorin
On 02/03/2010 01:59 PM, Sven Neumann wrote:
On Wed, 2010-02-03 at 13:55 +0200, Sorin Otescu wrote:
The BMP provider has a couple of bugs. The first is a faulty for
condition for 1bit BMPs. The second is an incorrect palette lookup for 1
and 4bit BMPs. Both of them are fixed by the attached patch, which is
unfortunately generated against DirectFB 1.0.
With all the whitespace changes in this patch it is very difficult to
spot the actual code changes. It would help a lot if you could split
this patch into two diffs. One that deals with whitespace issues and
another one that fixes the actual problem.
Sven
--- interfaces_IDirectFBImageProvider_idirectfbimageprovider_bmp.c 2010-02-03 14:01:48.000000000 +0200
+++ idirectfbimageprovider_bmp.c 2010-02-03 14:07:02.214488313 +0200
@@ -230,9 +230,9 @@
/* Palette */
if (data->indexed) {
void *src;
- int i;
+ int i, j;
- data->palette = src = D_MALLOC( data->num_colors*4 );
+ data->palette = src = D_MALLOC( 256*4 );
if (!data->palette)
return D_OOM();
@@ -248,7 +248,18 @@
c.g = ((u8*)src)[i*4+1];
c.b = ((u8*)src)[i*4+0];
+ /* For faster lookup, fill some of the 256 entries with duplicate data
+ for every bit position */
+ switch (data->num_colors) {
+ case 2:
+ for (j = 0; j < 8; j++)
+ data->palette[i << j] = c;
+ break;
+ case 4:
data->palette[i] = c;
+ data->palette[i << 4] = c;
+ break;
+ }
}
}
@@ -272,7 +283,7 @@
switch (data->depth) {
case 1:
- for (i = 0; data->width; i++) {
+ for (i = 0; i < data->width; i++) {
unsigned idx = buf[i>>3] & (0x80 >> (i&7));
DFBColor c = data->palette[idx];
dst[i] = c.b | (c.g << 8) | (c.r << 16) | (c.a << 24);
@@ -280,7 +291,7 @@
break;
case 4:
for (i = 0; i < data->width; i++) {
- unsigned idx = buf[i>>1] & (0xf0 >> (i&1));
+ unsigned idx = buf[i>>1] & (0xf0 >> ((i&1) << 2));
DFBColor c = data->palette[idx];
dst[i] = c.b | (c.g << 8) | (c.r << 16) | (c.a << 24);
}
_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev