gdi32: Add support for 4 bpp brushes.

This commit is contained in:
Huw Davies 2011-05-31 10:02:05 +01:00 committed by Alexandre Julliard
parent 850730dab5
commit 79e8eaeaf6
1 changed files with 175 additions and 0 deletions

View File

@ -536,6 +536,30 @@ static BOOL convert_to_8888(dib_info *dst, const dib_info *src, const RECT *src_
break;
}
case 4:
{
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
for(y = src_rect->top; y < src_rect->bottom; y++)
{
dst_pixel = dst_start;
src_pixel = src_start;
for(x = src_rect->left; x < src_rect->right; x++)
{
RGBQUAD rgb;
if(x & 1)
src_val = *src_pixel++ & 0xf;
else
src_val = (*src_pixel >> 4) & 0xf;
if(src_val >= src->color_table_size) src_val = src->color_table_size - 1;
rgb = src->color_table[src_val];
*dst_pixel++ = rgb.rgbRed << 16 | rgb.rgbGreen << 8 | rgb.rgbBlue;
}
dst_start += dst->stride / 4;
src_start += src->stride;
}
break;
}
default:
FIXME("Unsupported conversion: %d -> 8888\n", src->bit_count);
return FALSE;
@ -631,6 +655,32 @@ static BOOL convert_to_32(dib_info *dst, const dib_info *src, const RECT *src_re
break;
}
case 4:
{
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
for(y = src_rect->top; y < src_rect->bottom; y++)
{
dst_pixel = dst_start;
src_pixel = src_start;
for(x = src_rect->left; x < src_rect->right; x++)
{
RGBQUAD rgb;
if(x & 1)
src_val = *src_pixel++ & 0xf;
else
src_val = (*src_pixel >> 4) & 0xf;
if(src_val >= src->color_table_size) src_val = src->color_table_size - 1;
rgb = src->color_table[src_val];
*dst_pixel++ = put_field(rgb.rgbRed, dst->red_shift, dst->red_len) |
put_field(rgb.rgbGreen, dst->green_shift, dst->green_len) |
put_field(rgb.rgbBlue, dst->blue_shift, dst->blue_len);
}
dst_start += dst->stride / 4;
src_start += src->stride;
}
break;
}
default:
FIXME("Unsupported conversion: %d -> 32\n", src->bit_count);
return FALSE;
@ -724,6 +774,32 @@ static BOOL convert_to_555(dib_info *dst, const dib_info *src, const RECT *src_r
break;
}
case 4:
{
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
for(y = src_rect->top; y < src_rect->bottom; y++)
{
dst_pixel = dst_start;
src_pixel = src_start;
for(x = src_rect->left; x < src_rect->right; x++)
{
RGBQUAD rgb;
if(x & 1)
src_val = *src_pixel++ & 0xf;
else
src_val = (*src_pixel >> 4) & 0xf;
if(src_val >= src->color_table_size) src_val = src->color_table_size - 1;
rgb = src->color_table[src_val];
*dst_pixel++ = ((rgb.rgbRed << 7) & 0x7c00) |
((rgb.rgbGreen << 2) & 0x03e0) |
((rgb.rgbBlue >> 3) & 0x001f);
}
dst_start += dst->stride / 2;
src_start += src->stride;
}
break;
}
default:
FIXME("Unsupported conversion: %d -> 555\n", src->bit_count);
return FALSE;
@ -820,6 +896,32 @@ static BOOL convert_to_16(dib_info *dst, const dib_info *src, const RECT *src_re
break;
}
case 4:
{
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
for(y = src_rect->top; y < src_rect->bottom; y++)
{
dst_pixel = dst_start;
src_pixel = src_start;
for(x = src_rect->left; x < src_rect->right; x++)
{
RGBQUAD rgb;
if(x & 1)
src_val = *src_pixel++ & 0xf;
else
src_val = (*src_pixel >> 4) & 0xf;
if(src_val >= src->color_table_size) src_val = src->color_table_size - 1;
rgb = src->color_table[src_val];
*dst_pixel++ = put_field(rgb.rgbRed, dst->red_shift, dst->red_len) |
put_field(rgb.rgbGreen, dst->green_shift, dst->green_len) |
put_field(rgb.rgbBlue, dst->blue_shift, dst->blue_len);
}
dst_start += dst->stride / 2;
src_start += src->stride;
}
break;
}
default:
FIXME("Unsupported conversion: %d -> 16\n", src->bit_count);
return FALSE;
@ -940,6 +1042,30 @@ static BOOL convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
break;
}
case 4:
{
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
for(y = src_rect->top; y < src_rect->bottom; y++)
{
dst_pixel = dst_start;
src_pixel = src_start;
for(x = src_rect->left; x < src_rect->right; x++)
{
RGBQUAD rgb;
if(x & 1)
src_val = *src_pixel++ & 0xf;
else
src_val = (*src_pixel >> 4) & 0xf;
if(src_val >= src->color_table_size) src_val = src->color_table_size - 1;
rgb = src->color_table[src_val];
*dst_pixel++ = colorref_to_pixel_colortable(dst, RGB(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue));
}
dst_start += dst->stride;
src_start += src->stride;
}
break;
}
default:
FIXME("Unsupported conversion: %d -> 8\n", src->bit_count);
return FALSE;
@ -1056,6 +1182,55 @@ static BOOL convert_to_4(dib_info *dst, const dib_info *src, const RECT *src_rec
break;
}
case 4:
{
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
if(color_tables_match(dst, src) && (src_rect->left & 1) == 0)
{
if(src->stride > 0 && dst->stride > 0 && src_rect->left == 0 && src_rect->right == src->width)
memcpy(dst->bits, src_start, (src_rect->bottom - src_rect->top) * src->stride);
else
{
for(y = src_rect->top; y < src_rect->bottom; y++)
{
memcpy(dst_start, src_start, (src_rect->right - src_rect->left + 1) / 2);
dst_start += dst->stride;
src_start += src->stride;
}
}
}
else
{
for(y = src_rect->top; y < src_rect->bottom; y++)
{
dst_pixel = dst_start;
src_pixel = src_start;
for(x = src_rect->left; x < src_rect->right; x++)
{
RGBQUAD rgb;
if(x & 1)
src_val = *src_pixel++ & 0xf;
else
src_val = (*src_pixel >> 4) & 0xf;
if(src_val >= src->color_table_size) src_val = src->color_table_size - 1;
rgb = src->color_table[src_val];
dst_val = colorref_to_pixel_colortable(dst, RGB(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue));
if((x - src_rect->left) & 1)
{
*dst_pixel = (dst_val & 0x0f) | (*dst_pixel & 0xf0);
dst_pixel++;
}
else
*dst_pixel = (dst_val << 4) & 0xf0;
}
dst_start += dst->stride;
src_start += src->stride;
}
}
break;
}
default:
FIXME("Unsupported conversion: %d -> 4\n", src->bit_count);
return FALSE;