summaryrefslogtreecommitdiff
path: root/tools/genfont/genfont.c
diff options
context:
space:
mode:
authormrwastl <mrwastl@users.sourceforge.net>2011-06-29 01:17:41 +0200
committermrwastl <mrwastl@users.sourceforge.net>2011-06-29 01:17:41 +0200
commit0178c698712832d4d19e9303edacbe7e8a034891 (patch)
tree4283c7e775abff7d2d4530ca530954d2516bcf62 /tools/genfont/genfont.c
parent861d73246c73ae3201a9be96483d04f3cc5ba741 (diff)
downloadgraphlcd-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 'tools/genfont/genfont.c')
-rw-r--r--tools/genfont/genfont.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/tools/genfont/genfont.c b/tools/genfont/genfont.c
index ce9698d..980c55b 100644
--- a/tools/genfont/genfont.c
+++ b/tools/genfont/genfont.c
@@ -19,6 +19,8 @@
#include <glcdgraphics/bitmap.h>
#include <glcdgraphics/font.h>
+#include <glcdgraphics/image.h>
+#include <glcdgraphics/pbm.h>
static const char *prgname = "genfont";
static const char *version = "0.0.2";
@@ -138,9 +140,10 @@ int main(int argc, char *argv[])
fprintf(descFile, "spacebetween:%d\n", 0);
fprintf(descFile, "spacewidth:%d\n", 0);
- for (unsigned int i = 0; i < 256; i++)
+ for (uint32_t i = 0; i < 256; i++)
{
- const GLCD::cBitmap * charBitmap = font.GetCharacter((char) i);
+ const GLCD::cBitmap * charBitmap = font.GetCharacter(i);
+
if (charBitmap == NULL)
continue;
@@ -155,12 +158,33 @@ int main(int argc, char *argv[])
}
}
+ // invert image
+ for(int y=0; y < bitmap->Height(); y++) {
+ for(int x=0; x < bitmap->Width(); x++) {
+ bitmap->DrawPixel(x, y, GLCD::cColor(bitmap->GetPixel(x, y)).Invert());
+ }
+ }
+
if (posX > 0) // write last end marker
fprintf(descFile, "%d\n", posX);
fileName = outputName + ".pbm";
- bitmap->SavePBM(fileName);
- delete bitmap;
+
+ GLCD::cPBMFile pbm;
+ GLCD::cImage* image = new GLCD::cImage();
+
+ if (!image)
+ return 3;
+
+ image->AddBitmap(bitmap);
+
+ if (pbm.Save(*image, fileName) == false) {
+ fprintf(stderr, "Cannot save file: %s\n",fileName.c_str());
+ delete image;
+ return 2;
+ }
+
fclose(descFile);
+ delete image;
}
fprintf(stdout, "Font successfully generated.\n");