If smallest bitmap is too big, use it anyway at full size.

This commit is contained in:
ehouse 2009-01-18 19:52:46 +00:00
parent 50a6f93b99
commit 52a4a92e14

View file

@ -705,26 +705,30 @@ makeAndDrawBitmap( CEDrawCtx* dctx, HDC hdc, const RECT* bnds,
XP_Bool cached; XP_Bool cached;
XP_U16 index; XP_U16 index;
RECT lrt = *bnds; RECT lrt = *bnds;
XP_U16 useSize;
SIZE size; SIZE size;
GetTextExtentPoint32( hdc, L"M", 1, &size ); GetTextExtentPoint32( hdc, L"M", 1, &size );
useSize = size.cx;
if ( center ) {
lrt.left += ((lrt.right - lrt.left) - size.cx) / 2;
lrt.top += ((lrt.bottom - lrt.top) - size.cx) / 2;
}
lrt.right = lrt.left + size.cx;
lrt.bottom = lrt.top + size.cx;
for ( index = bitmaps->nBitmaps - 1; ; --index ) { for ( index = bitmaps->nBitmaps - 1; ; --index ) {
const CEBitmapInfo* info = (const CEBitmapInfo*)(bitmaps->bmps[index]); const CEBitmapInfo* info = (const CEBitmapInfo*)(bitmaps->bmps[index]);
if ( index == 0 ) { if ( info->nCols <= useSize && info->nRows <= useSize ) {
break; break;
} else if ( info->nCols <= size.cx && info->nRows <= size.cx ) { } else if ( index == 0 ) {
/* none fits */
useSize = XP_MAX( info->nCols, info->nRows );
break; break;
} }
} }
if ( center ) {
lrt.left += ((lrt.right - lrt.left) - useSize) / 2;
lrt.top += ((lrt.bottom - lrt.top) - useSize) / 2;
}
lrt.right = lrt.left + useSize;
lrt.bottom = lrt.top + useSize;
HBITMAP bm = checkBMCache( dctx, hdc, letters, index, bitmaps, &cached ); HBITMAP bm = checkBMCache( dctx, hdc, letters, index, bitmaps, &cached );
ceDrawBitmapInRect( hdc, &lrt, bm, XP_TRUE ); ceDrawBitmapInRect( hdc, &lrt, bm, XP_TRUE );