Clear and DrawStrings · ModusCreateOrg/creative-engine@4119fd9 · GitHub
Skip to content

Commit 4119fd9

Browse files
Clear and DrawStrings
1 parent 1d347a1 commit 4119fd9

3 files changed

Lines changed: 104 additions & 21 deletions

File tree

‎src/BBitmap.cpp‎

Lines changed: 67 additions & 4 deletions

‎src/BBitmap.h‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,10 @@ class BBitmap : public BBase {
118118
*
119119
* Return index in palette of found color, or -1 if not found.
120120
*/
121-
TInt FindColor(TRGB &aColor);
121+
TInt FindColor(const TRGB &aColor);
122122

123123
TInt FindColor(TInt aRed, TInt aGreen, TInt aBlue) {
124-
TRGB color(aRed, aGreen, aBlue);
125-
return FindColor(color);
124+
return FindColor(TRGB(aRed, aGreen, aBlue));
126125
}
127126

128127
/**
@@ -151,7 +150,7 @@ class BBitmap : public BBase {
151150
mPalette[index].Set(r, g, b);
152151
}
153152

154-
void SetColor(TUint8 index, TRGB aColor) {
153+
void SetColor(TUint8 index, const TRGB &aColor) {
155154
#ifndef PRODUCTION
156155
#if (defined(__XTENSA__) && defined(DEBUGME)) || !defined(__XTENSA__)
157156
printf("SetColor %d, %02x%02x%02x\n", index, aColor.r, aColor.g, aColor.b);
@@ -173,22 +172,27 @@ class BBitmap : public BBase {
173172

174173
TUint32 ReadPixel(TInt aX, TInt aY) { return mPixels[aY * mPitch + aX]; }
175174

176-
void WritePixel(TInt aX, TInt aY, TUint32 aColor) {
177-
mPixels[aY * mPitch + aX] = aColor;
175+
void WritePixel(TInt aX, TInt aY, const TRGB &aColor) {
176+
mPixels[aY * mPitch + aX] = aColor.rgb888();
178177
}
179178

180-
void SafeWritePixel(TInt aX, TInt aY, TUint32 aColor) {
179+
void SafeWritePixel(TInt aX, TInt aY, const TRGB &aColor) {
181180
if (mDimensions.PointInRect(aX, aY)) {
182-
WritePixel(aX, aY, aColor);
181+
WritePixel(aX, aY, aColor.rgb888());
183182
}
184183
}
185184

185+
void WritePixel(TInt aX, TInt aY, TUint8 aColor);
186+
187+
void SafeWritePixel(TInt aX, TInt aY, TUint8 aColor);
188+
186189
public:
187190
// DRAWING PRIMITIVES
188191
/**
189192
* Erase bitmap to specified color
190193
*/
191-
void Clear(TUint32 aColor = 0);
194+
void Clear(TUint8 aIndex = 0);
195+
void Clear(const TRGB &aColor);
192196

193197
/**
194198
* Copy the pixels from one bitmap to another.
@@ -279,6 +283,14 @@ class BBitmap : public BBase {
279283
TInt aDstX, TInt aDstY, TUint32 aFgColor, TInt32 aBgColor = -1,
280284
TInt aLetterSpacing = 0);
281285

286+
TBool DrawString(BViewPort *aViewPort, const char *aStr, const BFont *aFont,
287+
TInt aDstX, TInt aDstY, const TRGB &aFgColor, const TRGB &aBgColor,
288+
TInt aLetterSpacing = 0);
289+
290+
TBool DrawStringShadow(BViewPort *aViewPort, const char *aStr,
291+
const BFont *aFont, TInt aDstX, TInt aDstY, const TRGB &aFgColor,
292+
const TRGB &aShadowColor, const TRGB &aBgColor = -1, TInt aLetterSpacing = 0);
293+
282294
TBool DrawStringShadow(BViewPort *aViewPort, const char *aStr,
283295
const BFont *aFont, TInt aDstX, TInt aDstY, TUint32 aFgColor,
284296
TUint32 aShadowColor, TInt32 aBgColor = -1, TInt aLetterSpacing = 0);

‎src/Types/TRGB.h‎

Lines changed: 16 additions & 8 deletions

0 commit comments

Comments
 (0)