@@ -182,7 +182,7 @@ TInt BBitmap::NextUnusedColor() {
182182 return -1 ;
183183}
184184
185- TInt BBitmap::FindColor (TRGB &aColor) {
185+ TInt BBitmap::FindColor (const TRGB &aColor) {
186186 for (TInt ndx = 0 ; ndx < 256 ; ndx++) {
187187 if (mColorsUsed [ndx] && mPalette [ndx] == aColor) {
188188 return ndx;
@@ -641,9 +641,30 @@ TBool BBitmap::DrawStringShadow(BViewPort *aViewPort, const char *aStr,
641641 : EFalse;
642642}
643643
644+ TBool BBitmap::DrawStringShadow (BViewPort *aViewPort, const char *aStr, const BFont *aFont,
645+ TInt aX, TInt aY, const TRGB &aFgColor, const TRGB &aShadowColor,
646+ const TRGB &aBgColor, TInt aLetterSpacing) {
647+ const TInt32 bg = aBgColor == -1 ? -1 : aBgColor.rgb888 ();
648+ return DrawString (aViewPort, aStr, aFont, aX, aY, aShadowColor.rgb888 (), bg, aLetterSpacing)
649+ ? DrawString (aViewPort, aStr, aFont, aX - 1 , aY - 1 , aFgColor.rgb888 (), bg, aLetterSpacing)
650+ : EFalse;
651+ }
652+
653+ TBool BBitmap::DrawString (BViewPort *aViewPort, const char *aStr, const BFont *aFont,
654+ TInt aX, TInt aY, const TRGB &aFgColor, const TRGB &aBgColor,
655+ TInt aLetterSpacing) {
656+ const TInt32 bg = aBgColor == -1 ? -1 : aBgColor.rgb888 ();
657+ return DrawString (aViewPort, aStr, aFont, aX, aY, aFgColor.rgb888 (), bg, aLetterSpacing);
658+ }
659+
644660TBool BBitmap::DrawString (BViewPort *aViewPort, const char *aStr,
645661 const BFont *aFont, TInt aX, TInt aY, TUint32 aFgColor, TInt32 aBgColor,
646662 TInt aLetterSpacing) {
663+ if (gDisplay .renderBitmap ->mDepth == 32 ) {
664+ aFgColor = mPalette [aFgColor].rgb888 ();
665+ aBgColor = aBgColor == -1 ? -1 : mPalette [aBgColor].rgb888 ();
666+ }
667+
647668 const TInt fontWidth = aFont->mWidth ,
648669 fontHeight = aFont->mHeight ,
649670 charOffset = fontWidth + aLetterSpacing;
@@ -696,7 +717,6 @@ TBool BBitmap::DrawString(BViewPort *aViewPort, const char *aStr,
696717
697718 for (TInt y = charRect.y1 ; y < charRect.y2 ; y++, pixels += nextRow) {
698719 for (TInt x = charRect.x1 ; x < charRect.x2 ; x++, pixels++) {
699- // TUint32 pix = fontBitmap->ReadPixel(x, y);
700720 TUint32 pix = (fontBitmap->*ReadPixelByDepth)(x, y);
701721 // Write background and foreground pixels
702722 if (pix == 0 ) {
@@ -716,10 +736,53 @@ TBool BBitmap::DrawString(BViewPort *aViewPort, const char *aStr,
716736 return drawn;
717737}
718738
719- void BBitmap::Clear (TUint32 aColor) {
739+ void BBitmap::Clear (const TRGB &aColor) {
740+ const TInt len = mPitch * mHeight ;
741+
742+ if (aColor == 0 ) {
743+ memset (mPixels , 0 , len * sizeof (TUint32));
744+ return ;
745+ }
746+
747+ TUint32 color = aColor.rgb888 ();
748+ for (TInt i = 0 ; i < len; i++) {
749+ WritePixel (i, 0 , color);
750+ }
751+ }
752+
753+ void BBitmap::Clear (TUint8 aIndex) {
720754 const TInt len = mPitch * mHeight ;
755+
756+ if (gDisplay .renderBitmap ->mDepth == 32 ) {
757+ Clear (mPalette [aIndex]);
758+ return ;
759+ }
760+
761+ if (aIndex == 0 ) {
762+ memset (mPixels , aIndex, len * sizeof (TUint32));
763+ return ;
764+ }
765+
721766 for (TInt i = 0 ; i < len; i++) {
722- WritePixel (i, 0 , aColor);
767+ WritePixel (i, 0 , aIndex);
768+ }
769+ }
770+
771+ void BBitmap::WritePixel (TInt aX, TInt aY, TUint8 aIndex) {
772+ if (gDisplay .renderBitmap ->mDepth == 32 ) {
773+ WritePixel (aX, aY, mPalette [aIndex]);
774+ return ;
775+ }
776+ mPixels [aY * mPitch + aX] = aIndex;
777+ }
778+
779+ void BBitmap::SafeWritePixel (TInt aX, TInt aY, TUint8 aIndex) {
780+ if (mDimensions .PointInRect (aX, aY)) {
781+ if (gDisplay .renderBitmap ->mDepth == 32 ) {
782+ WritePixel (aX, aY, mPalette [aIndex]);
783+ return ;
784+ }
785+ WritePixel (aX, aY, aIndex);
723786 }
724787}
725788
0 commit comments