diff --git a/examples/font_drawing/font_drawing.ino b/examples/font_drawing/font_drawing.ino index 61f8f9f..50a787a 100644 --- a/examples/font_drawing/font_drawing.ino +++ b/examples/font_drawing/font_drawing.ino @@ -9,7 +9,6 @@ // work with the compressed font files created by the Group5 fontconvert tool // #include -#include "bb_font.h" #include #include "Roboto_Black_40.h" // BBF (BitBank Font file included as hex data to compile with the sketch) diff --git a/fontconvert/fontconvert.c b/fontconvert/fontconvert.c index 8f2418a..68be53f 100644 --- a/fontconvert/fontconvert.c +++ b/fontconvert/fontconvert.c @@ -21,7 +21,6 @@ #include FT_GLYPH_H #include FT_MODULE_H #include FT_TRUETYPE_DRIVER_H -#include "../src/bb_font.h" // BitBank font structures #include "../src/g5enc.inl" // Group5 image compression library G5ENCIMAGE g5enc; // Group5 encoder state diff --git a/imageconvert/Makefile b/imageconvert/Makefile new file mode 100644 index 0000000..9f108c1 --- /dev/null +++ b/imageconvert/Makefile @@ -0,0 +1,11 @@ +all: imgconvert + +CC = gcc +CFLAGS = -Wall + +imgconvert: main.c + $(CC) $(CFLAGS) $< -o $@ + strip $@ + +clean: + rm -f imgconvert diff --git a/imageconvert/main.c b/imageconvert/main.c new file mode 100644 index 0000000..f6ad235 --- /dev/null +++ b/imageconvert/main.c @@ -0,0 +1,143 @@ +// +// +// Group5 Image Compressor tool +// Written by Larry Bank +// Copyright (c) 2024 BitBank Software, Inc. +// + +#include +#include "../src/Group5.h" +#include "../src/g5enc.inl" +// +// Read a Windows BMP file into memory +// +uint8_t * ReadBMP(const char *fname, int *width, int *height, int *bpp, unsigned char *pPal) +{ + int y, w, h, bits, offset; + uint8_t *s, *d, *pTemp, *pBitmap; + int pitch, bytewidth; + int iSize, iDelta; + FILE *infile; + + infile = fopen(fname, "r+b"); + if (infile == NULL) { + printf("Error opening input file %s\n", fname); + return NULL; + } + // Read the bitmap into RAM + fseek(infile, 0, SEEK_END); + iSize = (int)ftell(infile); + fseek(infile, 0, SEEK_SET); + pBitmap = (uint8_t *)malloc(iSize); + pTemp = (uint8_t *)malloc(iSize); + fread(pTemp, 1, iSize, infile); + fclose(infile); + + if (pTemp[0] != 'B' || pTemp[1] != 'M' || pTemp[14] < 0x28) { + free(pBitmap); + free(pTemp); + printf("Not a Windows BMP file!\n"); + return NULL; + } + w = *(int32_t *)&pTemp[18]; + h = *(int32_t *)&pTemp[22]; + bits = *(int16_t *)&pTemp[26] * *(int16_t *)&pTemp[28]; + if (bits <= 8 && pPal != NULL) { // it has a palette, copy it + uint8_t *p = pPal; + for (int i=0; i<(1<> 3; + } else { + bytewidth = (w * bits) >> 3; + } + pitch = (bytewidth + 3) & 0xfffc; // DWORD aligned +// move up the pixels + d = pBitmap; + s = &pTemp[offset]; + iDelta = pitch; + if (h > 0) { + iDelta = -pitch; + s = &pTemp[offset + (h-1) * pitch]; + } else { + h = -h; + } + for (y=0; y \n"); + return -1; + } + pBMP = ReadBMP(argv[1], &w, &h, &bpp, NULL); + if (bpp == 1) { + uint8_t *s = pBMP; + + printf("bmp size %d x %d\n", w, h); + iPitch = (w+7) >> 3; + pOut = (uint8_t *)malloc(iPitch * h); + rc = g5_encode_init(&g5enc, w, h, pOut, iPitch * h); + for (y=0; y