diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2011-06-29 01:17:41 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2011-06-29 01:17:41 +0200 |
commit | 0178c698712832d4d19e9303edacbe7e8a034891 (patch) | |
tree | 4283c7e775abff7d2d4530ca530954d2516bcf62 /glcdgraphics/font.c | |
parent | 861d73246c73ae3201a9be96483d04f3cc5ba741 (diff) | |
download | graphlcd-base-0178c698712832d4d19e9303edacbe7e8a034891.tar.gz graphlcd-base-0178c698712832d4d19e9303edacbe7e8a034891.tar.bz2 |
fix saving of PBMs, fix crtfont and genfont; remove cBitmap::LoadPBM()/::SavePBM (use cPMFile::Load()/Save()) instead; fixed cBitmap::SubBitmap(); add static methods for converting from and to 1BPP
Diffstat (limited to 'glcdgraphics/font.c')
-rw-r--r-- | glcdgraphics/font.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/glcdgraphics/font.c b/glcdgraphics/font.c index ff42514..24a44a0 100644 --- a/glcdgraphics/font.c +++ b/glcdgraphics/font.c @@ -176,6 +176,7 @@ bool cFont::LoadFNT(const std::string & fileName, const std::string & encoding) int num = 0; uint dot; uint b; cBitmap * charBitmap = new cBitmap(charWidth, fontHeight); + charBitmap->SetMonochrome(true); charBitmap->Clear(); for (num=0; num<fontHeight * ((charWidth + 7) / 8);num++) { y = (charWidth + 7) / 8; @@ -220,7 +221,7 @@ bool cFont::SaveFNT(const std::string & fileName) const numChars = 0; for (i = 0; i < 256; i++) { - if (characters[i]) + if (GetCharacter(i)) { numChars++; } @@ -243,17 +244,20 @@ bool cFont::SaveFNT(const std::string & fileName) const // write font file header fwrite(fhdr, kFontHeaderSize, 1, fontFile); + const cBitmap* charbmp = NULL; for (i = 0; i < 256; i++) { - if (characters[i]) + charbmp = GetCharacter(i); + if (charbmp) { chdr[0] = (uint8_t) i; chdr[1] = (uint8_t) (i >> 8); - chdr[2] = (uint8_t) characters[i]->Width(); - chdr[3] = (uint8_t) (characters[i]->Width() >> 8); + chdr[2] = (uint8_t) charbmp->Width(); + chdr[3] = (uint8_t) (charbmp->Width() >> 8); fwrite(chdr, kCharHeaderSize, 1, fontFile); -// fwrite(characters[i]->Data(), totalHeight * characters[i]->LineSize(), 1, fontFile); - fwrite(characters[i]->Data(), totalHeight * characters[i]->Width(), 1, fontFile); + const unsigned char* monobmp = cBitmap::ConvertTo1BPP(*charbmp); + fwrite(monobmp /*characters[i]->Data()*/, totalHeight * ((charbmp->Width() + 7) / 8), 1, fontFile); + delete[] monobmp; } } @@ -467,7 +471,8 @@ const cBitmap * cFont::GetCharacter(uint32_t ch) const } else { // now, fill our pixel data cBitmap *charBitmap = new cBitmap(face->glyph->advance.x >> 6, TotalHeight()); - charBitmap->Clear(); + charBitmap->Clear(cColor::White); + charBitmap->SetMonochrome(true); unsigned char * bufPtr = face->glyph->bitmap.buffer; unsigned char pixel; for (int y = 0; y < face->glyph->bitmap.rows; y++) |