gdi32: Add an all-one alpha channel when converting a DIB for blending.

This commit is contained in:
Alexandre Julliard 2011-10-12 17:57:02 +02:00
parent 7c648cb695
commit 8f4d50ea4b
4 changed files with 20 additions and 9 deletions

View File

@ -160,7 +160,7 @@ void free_heap_bits( struct gdi_image_bits *bits )
}
static DWORD convert_bits( const BITMAPINFO *src_info, struct bitblt_coords *src,
BITMAPINFO *dst_info, struct gdi_image_bits *bits )
BITMAPINFO *dst_info, struct gdi_image_bits *bits, BOOL add_alpha )
{
void *ptr;
DWORD err;
@ -169,7 +169,7 @@ static DWORD convert_bits( const BITMAPINFO *src_info, struct bitblt_coords *src
if (!(ptr = HeapAlloc( GetProcessHeap(), 0, get_dib_image_size( dst_info ))))
return ERROR_OUTOFMEMORY;
err = convert_bitmapinfo( src_info, bits->ptr, src, dst_info, ptr );
err = convert_bitmapinfo( src_info, bits->ptr, src, dst_info, ptr, add_alpha );
if (bits->free) bits->free( bits );
bits->ptr = ptr;
bits->is_copy = TRUE;
@ -252,7 +252,7 @@ BOOL nulldrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
dst_info->bmiHeader.biClrUsed = 1;
}
if (!(err = convert_bits( src_info, src, dst_info, &bits )))
if (!(err = convert_bits( src_info, src, dst_info, &bits, FALSE )))
{
/* get rid of the fake 1-bpp table */
if (dst_info->bmiHeader.biClrUsed == 1) dst_info->bmiHeader.biClrUsed = 0;
@ -309,7 +309,7 @@ BOOL nulldrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords *dst,
src_info->bmiHeader.biClrUsed = 2;
}
err = convert_bits( src_info, src, dst_info, &bits );
err = convert_bits( src_info, src, dst_info, &bits, TRUE );
if (!err) err = dst_dev->funcs->pBlendImage( dst_dev, dst_info, &bits, src, dst, func );
}

View File

@ -591,7 +591,7 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
ptr = HeapAlloc( GetProcessHeap(), 0, get_dib_image_size( dst_info ));
if (ptr)
{
err = convert_bitmapinfo( src_info, src_bits.ptr, &src, dst_info, ptr );
err = convert_bitmapinfo( src_info, src_bits.ptr, &src, dst_info, ptr, FALSE );
if (src_bits.free) src_bits.free( &src_bits );
src_bits.ptr = ptr;
src_bits.is_copy = TRUE;
@ -721,7 +721,7 @@ INT nulldrv_SetDIBitsToDevice( PHYSDEV dev, INT x_dst, INT y_dst, DWORD cx, DWOR
ptr = HeapAlloc( GetProcessHeap(), 0, get_dib_image_size( dst_info ));
if (ptr)
{
err = convert_bitmapinfo( src_info, src_bits.ptr, &src, dst_info, ptr );
err = convert_bitmapinfo( src_info, src_bits.ptr, &src, dst_info, ptr, FALSE );
if (src_bits.free) src_bits.free( &src_bits );
src_bits.ptr = ptr;
src_bits.is_copy = TRUE;
@ -1226,7 +1226,7 @@ INT WINAPI GetDIBits(
else
dst_info->bmiHeader.biHeight = -src.height;
convert_bitmapinfo( src_info, src_bits.ptr, &src, dst_info, bits );
convert_bitmapinfo( src_info, src_bits.ptr, &src, dst_info, bits, FALSE );
if (src_bits.free) src_bits.free( &src_bits );
ret = lines;
}

View File

@ -278,7 +278,7 @@ void copy_dib_color_info(dib_info *dst, const dib_info *src)
}
DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bitblt_coords *src,
const BITMAPINFO *dst_info, void *dst_bits )
const BITMAPINFO *dst_info, void *dst_bits, BOOL add_alpha )
{
dib_info src_dib, dst_dib;
DWORD ret;
@ -306,6 +306,17 @@ DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
src->x -= src->visrect.left;
src->y -= src->visrect.top;
offset_rect( &src->visrect, -src->visrect.left, -src->visrect.top );
if (add_alpha && dst_dib.funcs == &funcs_8888 && src_dib.funcs != &funcs_8888)
{
DWORD *pixel = dst_dib.bits.ptr;
int x, y;
for (y = src->visrect.top; y < src->visrect.bottom; y++, pixel += dst_dib.stride / 4)
for (x = src->visrect.left; x < src->visrect.right; x++)
pixel[x] |= 0xff000000;
}
return ERROR_SUCCESS;
}

View File

@ -252,7 +252,7 @@ extern void DC_UpdateXforms( DC * dc ) DECLSPEC_HIDDEN;
/* dib.c */
extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
extern DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bitblt_coords *src,
const BITMAPINFO *dst_info, void *dst_bits ) DECLSPEC_HIDDEN;
const BITMAPINFO *dst_info, void *dst_bits, BOOL add_alpha ) DECLSPEC_HIDDEN;
extern DWORD stretch_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bitblt_coords *src,
const BITMAPINFO *dst_info, void *dst_bits, struct bitblt_coords *dst,