2018-02-21 19:36:38 +08:00
|
|
|
/**
|
|
|
|
* File: main.c
|
2018-05-15 09:31:58 +08:00
|
|
|
* Author: AWTK Develop Team
|
2018-02-21 19:36:38 +08:00
|
|
|
* Brief: bitmap font generator
|
|
|
|
*
|
2019-01-07 10:58:36 +08:00
|
|
|
* Copyright (c) 2018 - 2019 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
2018-02-21 19:36:38 +08:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* License file for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* History:
|
|
|
|
* ================================================================
|
|
|
|
* 2018-01-21 Li XianJing <xianjimli@hotmail.com> created
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-12-15 17:22:05 +08:00
|
|
|
#include "tkc/mem.h"
|
2018-02-21 19:36:38 +08:00
|
|
|
#include "image_gen.h"
|
2018-03-18 11:29:31 +08:00
|
|
|
#include "common/utils.h"
|
|
|
|
#include "base/image_manager.h"
|
2018-02-21 19:36:38 +08:00
|
|
|
#include "image_loader/image_loader_stb.h"
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
2018-02-22 11:37:13 +08:00
|
|
|
bitmap_t image;
|
2018-03-18 11:29:31 +08:00
|
|
|
uint32_t size = 0;
|
|
|
|
uint8_t* buff = NULL;
|
2019-08-12 10:47:09 +08:00
|
|
|
bool_t mono = FALSE;
|
2018-10-17 09:57:36 +08:00
|
|
|
bool_t require_bgra = FALSE;
|
|
|
|
bool_t enable_bgr565 = FALSE;
|
2018-02-21 19:36:38 +08:00
|
|
|
const char* in_filename = NULL;
|
|
|
|
const char* out_filename = NULL;
|
2018-02-22 11:37:13 +08:00
|
|
|
|
2018-05-04 11:45:09 +08:00
|
|
|
TKMEM_INIT(4 * 1024 * 1024);
|
2018-02-21 19:36:38 +08:00
|
|
|
|
2018-10-17 09:57:36 +08:00
|
|
|
if (argc < 3) {
|
2019-08-12 10:47:09 +08:00
|
|
|
printf("Usage: %s in_filename out_filename (bgra|bgr565|mono)\n", argv[0]);
|
2018-02-21 19:36:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-17 09:57:36 +08:00
|
|
|
if (argc >= 4) {
|
|
|
|
const char* options = argv[3];
|
|
|
|
|
2019-08-12 10:47:09 +08:00
|
|
|
if (strstr(options, "mono") != NULL) {
|
|
|
|
mono = TRUE;
|
|
|
|
}
|
|
|
|
|
2018-10-17 09:57:36 +08:00
|
|
|
if (strstr(options, "bgra") != NULL) {
|
|
|
|
require_bgra = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strstr(options, "bgr565") != NULL) {
|
|
|
|
enable_bgr565 = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-21 19:36:38 +08:00
|
|
|
in_filename = argv[1];
|
|
|
|
out_filename = argv[2];
|
2018-11-02 11:51:14 +08:00
|
|
|
|
|
|
|
exit_if_need_not_update(in_filename, out_filename);
|
|
|
|
|
2018-03-18 11:29:31 +08:00
|
|
|
buff = (uint8_t*)read_file(in_filename, &size);
|
2018-03-18 17:02:10 +08:00
|
|
|
if (buff != NULL) {
|
2018-11-25 18:57:44 +08:00
|
|
|
if (stb_load_image(0, buff, size, &image, require_bgra, enable_bgr565) == RET_OK) {
|
2019-08-12 10:47:09 +08:00
|
|
|
if (image_gen(&image, out_filename, mono) == RET_OK) {
|
2018-03-18 11:29:31 +08:00
|
|
|
printf("done\n");
|
|
|
|
} else {
|
|
|
|
printf("gen %s failed\n", out_filename);
|
|
|
|
}
|
2018-02-21 19:36:38 +08:00
|
|
|
} else {
|
2018-03-18 11:29:31 +08:00
|
|
|
printf("load %s failed\n", in_filename);
|
2018-02-21 19:36:38 +08:00
|
|
|
}
|
2018-10-08 16:37:20 +08:00
|
|
|
TKMEM_FREE(buff);
|
2018-02-21 19:36:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|