Lines 225-231
Link Here
|
225 |
const Size aTotalSize( nInitSize * nItemWidth, nItemHeight ); |
225 |
const Size aTotalSize( nInitSize * nItemWidth, nItemHeight ); |
226 |
|
226 |
|
227 |
maBmpEx = Bitmap( aTotalSize, 24 ); |
227 |
maBmpEx = Bitmap( aTotalSize, 24 ); |
228 |
maDisabledBmp.SetEmpty(); |
228 |
maDisabledBmpEx.SetEmpty(); |
229 |
|
229 |
|
230 |
delete mpDisplayBmp; |
230 |
delete mpDisplayBmp; |
231 |
mpDisplayBmp = NULL; |
231 |
mpDisplayBmp = NULL; |
Lines 243-249
Link Here
|
243 |
void ImplImageBmp::Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight, USHORT nInitSize ) |
243 |
void ImplImageBmp::Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight, USHORT nInitSize ) |
244 |
{ |
244 |
{ |
245 |
maBmpEx = rBmpEx; |
245 |
maBmpEx = rBmpEx; |
246 |
maDisabledBmp.SetEmpty(); |
246 |
maDisabledBmpEx.SetEmpty(); |
247 |
|
247 |
|
248 |
delete mpDisplayBmp; |
248 |
delete mpDisplayBmp; |
249 |
mpDisplayBmp = NULL; |
249 |
mpDisplayBmp = NULL; |
Lines 268-275
Link Here
|
268 |
|
268 |
|
269 |
maBmpEx.Expand( nDX, 0UL ); |
269 |
maBmpEx.Expand( nDX, 0UL ); |
270 |
|
270 |
|
271 |
if( !maDisabledBmp.IsEmpty() ) |
271 |
if( !maDisabledBmpEx.IsEmpty() ) |
272 |
maDisabledBmp.Expand( nDX, 0UL ); |
272 |
maDisabledBmpEx.Expand( nDX, 0UL ); |
273 |
|
273 |
|
274 |
delete mpDisplayBmp; |
274 |
delete mpDisplayBmp; |
275 |
mpDisplayBmp = NULL; |
275 |
mpDisplayBmp = NULL; |
Lines 300-307
Link Here
|
300 |
|
300 |
|
301 |
maBmpEx.CopyPixel( aDstRect, aSrcRect ); |
301 |
maBmpEx.CopyPixel( aDstRect, aSrcRect ); |
302 |
|
302 |
|
303 |
if( !maDisabledBmp.IsEmpty() ) |
303 |
if( !maDisabledBmpEx.IsEmpty() ) |
304 |
maDisabledBmp.CopyPixel( aDstRect, aSrcRect ); |
304 |
maDisabledBmpEx.CopyPixel( aDstRect, aSrcRect ); |
305 |
|
305 |
|
306 |
delete mpDisplayBmp; |
306 |
delete mpDisplayBmp; |
307 |
mpDisplayBmp = NULL; |
307 |
mpDisplayBmp = NULL; |
Lines 412-419
Link Here
|
412 |
|
412 |
|
413 |
ImplUpdateDisabledBmp( -1 ); |
413 |
ImplUpdateDisabledBmp( -1 ); |
414 |
|
414 |
|
415 |
pOutDev->DrawMask( aOutPos1, aOutSize, aSrcPos, maSize, maDisabledBmp, rSettings.GetLightColor() ); |
415 |
if( maDisabledBmpEx.IsAlpha() ) |
416 |
pOutDev->DrawMask( rPos, aOutSize, aSrcPos, maSize, maDisabledBmp, rSettings.GetShadowColor() ); |
416 |
pOutDev->DrawBitmapEx( rPos, aOutSize, aSrcPos, maSize, maDisabledBmpEx ); |
|
|
417 |
else |
418 |
{ |
419 |
pOutDev->DrawMask( aOutPos1, aOutSize, aSrcPos, maSize, maDisabledBmpEx.GetBitmap(), |
420 |
rSettings.GetLightColor() ); |
421 |
pOutDev->DrawMask( rPos, aOutSize, aSrcPos, maSize, maDisabledBmpEx.GetBitmap(), |
422 |
rSettings.GetShadowColor() ); |
423 |
} |
417 |
} |
424 |
} |
418 |
else |
425 |
else |
419 |
{ |
426 |
{ |
Lines 590-749
Link Here
|
590 |
|
597 |
|
591 |
// ----------------------------------------------------------------------- |
598 |
// ----------------------------------------------------------------------- |
592 |
|
599 |
|
593 |
void ImplImageBmp::ImplUpdateDisabledBmp( int nPos ) |
600 |
static unsigned char deSaturate (unsigned char col, unsigned char intensity) |
594 |
{ |
601 |
{ |
595 |
if( ( nPos >= 0 && !maDisabledBmp.IsEmpty() ) || |
602 |
int i = (int) ((0.2 * intensity + col * 0.8) * 0.7); |
596 |
( nPos < 0 && maDisabledBmp.IsEmpty() ) ) |
603 |
if (i <= 0) |
597 |
{ |
604 |
return 0; |
598 |
Bitmap aBmp( maBmpEx.GetBitmap() ); |
605 |
if (i >= 255) |
599 |
Bitmap aMask; |
606 |
return 255; |
|
|
607 |
return i; |
608 |
} |
600 |
|
609 |
|
601 |
if( maBmpEx.IsTransparent() ) |
610 |
void ImplImageBmp::ImplUpdateDisabledBmp( int nPos ) |
602 |
aMask = maBmpEx.GetMask(); |
611 |
{ |
603 |
else |
612 |
if( ! ( nPos >= 0 && !maDisabledBmpEx.IsEmpty() ) && |
604 |
{ |
613 |
! ( nPos < 0 && maDisabledBmpEx.IsEmpty() ) ) |
605 |
aMask = aBmp; |
614 |
return; |
606 |
aMask.Convert( BMP_CONVERSION_1BIT_THRESHOLD ); |
615 |
|
607 |
} |
616 |
Bitmap aBitmap; |
608 |
|
617 |
|
609 |
if( maDisabledBmp.IsEmpty() ) |
618 |
if( maBmpEx.IsAlpha() ) |
610 |
maDisabledBmp = Bitmap( aBmp.GetSizePixel(), 1 ); |
619 |
aBitmap = Bitmap( maBmpEx.GetSizePixel(), |
611 |
|
620 |
maBmpEx.GetBitCount() ); |
612 |
BitmapReadAccess* pAcc = aBmp.AcquireReadAccess(); |
621 |
else |
613 |
BitmapReadAccess* pMsk = aMask.AcquireReadAccess(); |
622 |
aBitmap = Bitmap( maBmpEx.GetSizePixel(), 1 ); |
614 |
BitmapWriteAccess* pDis = maDisabledBmp.AcquireWriteAccess(); |
623 |
|
|
|
624 |
Bitmap aSrcBitmap = maBmpEx.GetBitmap(); |
625 |
BitmapReadAccess *pAcc = aSrcBitmap.AcquireReadAccess(); |
626 |
if( !pAcc ) |
627 |
return; |
628 |
BitmapWriteAccess *pDis = aBitmap.AcquireWriteAccess(); |
615 |
|
629 |
|
616 |
if( pAcc && pMsk && pDis ) |
630 |
if( !pDis ) |
617 |
{ |
631 |
{ |
618 |
const Color aWhite( COL_WHITE ); |
632 |
aSrcBitmap.ReleaseAccess( pAcc ); |
619 |
const Color aBlack( COL_BLACK ); |
633 |
return; |
620 |
const BitmapColor aAccWhite( pAcc->GetBestMatchingColor( aWhite ) ); |
634 |
} |
621 |
const BitmapColor aMskWhite( pMsk->GetBestMatchingColor( aWhite ) ); |
|
|
622 |
const BitmapColor aDisWhite( pDis->GetBestMatchingColor( aWhite ) ); |
623 |
const BitmapColor aDisBlack( pDis->GetBestMatchingColor( aBlack ) ); |
624 |
long nLeft, nTop, nRight, nBottom; |
625 |
long nCurLeft, nCurRight; |
626 |
const long nBlackThreshold = FRound( maSize.Width() * maSize.Height() * 0.10 ); |
627 |
|
635 |
|
628 |
if( nPos >= 0 ) |
636 |
long nLeft, nTop, nRight, nBottom; |
629 |
{ |
|
|
630 |
const Point aPos( nPos * maSize.Width(), 0 ); |
631 |
|
637 |
|
632 |
nLeft = aPos.X(); |
638 |
if( nPos >= 0 ) |
633 |
nTop = 0; |
639 |
{ |
634 |
nRight = nLeft + maSize.Width(); |
640 |
const Point aPos( nPos * maSize.Width(), 0 ); |
635 |
nBottom = nTop + maSize.Height(); |
|
|
636 |
} |
637 |
else |
638 |
{ |
639 |
nLeft = nTop = 0L; |
640 |
nRight = pDis->Width(); |
641 |
nBottom = pDis->Height(); |
642 |
} |
643 |
|
641 |
|
644 |
nCurLeft = nLeft; |
642 |
nLeft = aPos.X(); |
645 |
nCurRight = nCurLeft + maSize.Width(); |
643 |
nTop = 0; |
|
|
644 |
nRight = nLeft + maSize.Width(); |
645 |
nBottom = nTop + maSize.Height(); |
646 |
} |
647 |
else |
648 |
{ |
649 |
nLeft = nTop = 0L; |
650 |
nRight = pDis->Width(); |
651 |
nBottom = pDis->Height(); |
652 |
} |
646 |
|
653 |
|
647 |
while( nCurLeft < nRight ) |
654 |
if( maBmpEx.IsAlpha() ) |
|
|
655 |
{ |
656 |
if( pAcc && pDis ) |
657 |
{ |
658 |
for( long nY = nTop; nY < nBottom; nY++ ) |
648 |
{ |
659 |
{ |
649 |
sal_Int32 nBlackCount = 0; |
660 |
for( long nX = nLeft; nX < nRight; nX++ ) |
650 |
|
661 |
{ |
651 |
if( pAcc->GetScanlineFormat() == BMP_FORMAT_4BIT_MSN_PAL && |
662 |
BitmapColor col = pAcc->GetPixel( nY, nX ); |
652 |
pMsk->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL ) |
663 |
unsigned char i; |
653 |
{ |
664 |
|
654 |
// optimized version |
665 |
i = (unsigned char ) ( col.GetRed() * 0.3 + // magic numbers |
655 |
const BYTE cAccTest = aAccWhite.GetIndex(); |
666 |
col.GetGreen() * 0.59 + |
656 |
const BYTE cMskTest = aMskWhite.GetIndex(); |
667 |
col.GetBlue () * 0.11 ); |
657 |
|
668 |
if ((nY + nX) % 2 == 0) |
658 |
for( long nY = nTop; nY < nBottom; nY++ ) |
|
|
659 |
{ |
660 |
Scanline pAccScan = pAcc->GetScanline( nY ); |
661 |
Scanline pMskScan = pMsk->GetScanline( nY ); |
662 |
|
663 |
for( long nX = nCurLeft; nX < nCurRight; nX++ ) |
664 |
{ |
665 |
if( ( cMskTest == ( pMskScan[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 ) ) || |
666 |
( cAccTest == ( ( pAccScan[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f ) ) ) |
667 |
{ |
668 |
pDis->SetPixel( nY, nX, aDisWhite ); |
669 |
} |
670 |
else |
671 |
{ |
672 |
pDis->SetPixel( nY, nX, aDisBlack ); |
673 |
++nBlackCount; |
674 |
} |
675 |
} |
676 |
} |
677 |
} |
678 |
else if( pAcc->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL && |
679 |
pMsk->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL ) |
680 |
{ |
681 |
// optimized version |
682 |
const BYTE cAccTest = aAccWhite.GetIndex(); |
683 |
const BYTE cMskTest = aMskWhite.GetIndex(); |
684 |
|
685 |
for( long nY = nTop; nY < nBottom; nY++ ) |
686 |
{ |
669 |
{ |
687 |
Scanline pAccScan = pAcc->GetScanline( nY ); |
670 |
col.SetRed (i / 2 + 127); |
688 |
Scanline pMskScan = pMsk->GetScanline( nY ); |
671 |
col.SetGreen (i / 2 + 127); |
689 |
|
672 |
col.SetBlue (i / 2 + 127); |
690 |
for( long nX = nCurLeft; nX < nCurRight; nX++ ) |
|
|
691 |
{ |
692 |
if( ( cMskTest == ( pMskScan[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 ) ) || |
693 |
( cAccTest == pAccScan[ nX ] ) ) |
694 |
{ |
695 |
pDis->SetPixel( nY, nX, aDisWhite ); |
696 |
} |
697 |
else |
698 |
{ |
699 |
pDis->SetPixel( nY, nX, aDisBlack ); |
700 |
++nBlackCount; |
701 |
} |
702 |
} |
703 |
} |
673 |
} |
704 |
} |
674 |
else |
705 |
else |
|
|
706 |
{ |
707 |
for( long nY = nTop; nY < nBottom; nY++ ) |
708 |
{ |
675 |
{ |
709 |
for( long nX = nCurLeft; nX < nCurRight; nX++ ) |
676 |
col.SetRed (deSaturate (col.GetRed(), i)); |
710 |
{ |
677 |
col.SetGreen (deSaturate (col.GetGreen(), i)); |
711 |
if( ( aMskWhite == pMsk->GetPixel( nY, nX ) ) || |
678 |
col.SetBlue (deSaturate (col.GetBlue(), i)); |
712 |
( aAccWhite == pAcc->GetPixel( nY, nX ) ) ) |
|
|
713 |
{ |
714 |
pDis->SetPixel( nY, nX, aDisWhite ); |
715 |
} |
716 |
else |
717 |
{ |
718 |
pDis->SetPixel( nY, nX, aDisBlack ); |
719 |
++nBlackCount; |
720 |
} |
721 |
} |
722 |
} |
679 |
} |
|
|
680 |
pDis->SetPixel( nY, nX, col ); |
723 |
} |
681 |
} |
|
|
682 |
} |
683 |
} |
684 |
} |
685 |
else |
686 |
{ |
687 |
BitmapReadAccess *pMsk = aBitmap.AcquireReadAccess(); |
724 |
|
688 |
|
725 |
if( nBlackCount < nBlackThreshold ) |
689 |
const Color aWhite( COL_WHITE ); |
726 |
{ |
690 |
const Color aBlack( COL_BLACK ); |
727 |
// emergency solution if paint bitmap is mostly white |
691 |
const BitmapColor aAccWhite( pAcc->GetBestMatchingColor( aWhite ) ); |
728 |
for( long nY = nTop; nY < nBottom; nY++ ) |
692 |
const BitmapColor aMskWhite( pMsk->GetBestMatchingColor( aWhite ) ); |
729 |
{ |
693 |
const BitmapColor aDisWhite( pDis->GetBestMatchingColor( aWhite ) ); |
730 |
for( long nX = nCurLeft; nX < nCurRight; nX++ ) |
694 |
const BitmapColor aDisBlack( pDis->GetBestMatchingColor( aBlack ) ); |
731 |
{ |
|
|
732 |
if( aMskWhite == pMsk->GetPixel( nY, nX ) ) |
733 |
pDis->SetPixel( nY, nX, aDisWhite ); |
734 |
else |
735 |
pDis->SetPixel( nY, nX, aDisBlack ); |
736 |
} |
737 |
} |
738 |
} |
739 |
|
695 |
|
740 |
nCurLeft += maSize.Width(); |
696 |
for( long nY = nTop; nY < nBottom; nY++ ) |
741 |
nCurRight += maSize.Width(); |
697 |
{ |
|
|
698 |
for( long nX = nLeft; nX < nRight; nX++ ) |
699 |
{ |
700 |
if( ( aMskWhite == pMsk->GetPixel( nY, nX ) ) && |
701 |
( aAccWhite != pAcc->GetPixel( nY, nX ) ) ) |
702 |
pDis->SetPixel( nY, nX, aDisBlack ); |
703 |
else |
704 |
pDis->SetPixel( nY, nX, aDisWhite ); |
742 |
} |
705 |
} |
743 |
} |
706 |
} |
744 |
|
707 |
aBitmap.ReleaseAccess( pMsk ); |
745 |
aBmp.ReleaseAccess( pAcc ); |
|
|
746 |
aMask.ReleaseAccess( pMsk ); |
747 |
maDisabledBmp.ReleaseAccess( pDis ); |
748 |
} |
708 |
} |
|
|
709 |
|
710 |
aSrcBitmap.ReleaseAccess( pAcc ); |
711 |
aBitmap.ReleaseAccess( pDis ); |
712 |
|
713 |
if( maBmpEx.IsAlpha() ) |
714 |
maDisabledBmpEx = BitmapEx( aBitmap, maBmpEx.GetAlpha() ); |
715 |
else |
716 |
maDisabledBmpEx = BitmapEx( aBitmap ); |
749 |
} |
717 |
} |