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 ff89bee6e8
commit 09cc644a4c

View file

@ -705,26 +705,30 @@ makeAndDrawBitmap( CEDrawCtx* dctx, HDC hdc, const RECT* bnds,
XP_Bool cached;
XP_U16 index;
RECT lrt = *bnds;
XP_U16 useSize;
SIZE size;
GetTextExtentPoint32( hdc, L"M", 1, &size );
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;
useSize = size.cx;
for ( index = bitmaps->nBitmaps - 1; ; --index ) {
const CEBitmapInfo* info = (const CEBitmapInfo*)(bitmaps->bmps[index]);
if ( index == 0 ) {
if ( info->nCols <= useSize && info->nRows <= useSize ) {
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;
}
}
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 );
ceDrawBitmapInRect( hdc, &lrt, bm, XP_TRUE );