void tga_save_png(const char *name) { char convert_cmd[1024*2]; tga_save("tmp.tga"); sprintf(convert_cmd, "convert tmp.tga -trim %s", name ); system(convert_cmd); }
void save_picture(ucg_t *ucg, const char *fname) { tga_save("ucg_pic.tga"); { char cmd[256]; sprintf(cmd, "convert ucg_pic.tga -scale 200%% %s.png", fname); system(cmd); } }
int main(void) { u8x8_Setup_TGA_DESC(&u8x8); u8x8_InitDisplay(&u8x8); u8x8_SetPowerSave(&u8x8, 0); u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_r ); u8x8_DrawString(&u8x8, 0, 0, "Hello World!"); tga_save("u8x8.tga"); return 0; }
void write_tga_map(const char *filename) { static u8g2_t u8g2; int x, y, i; unsigned tile; if ( map_phase != PHASE_MAPDATA ) return; u8x8_tga_info.tile_width = map_width*2; u8x8_tga_info.tile_height = map_height*2; u8x8_tga_info.pixel_width = map_width*16; u8x8_tga_info.pixel_height = map_height*16; u8g2_SetupBuffer_TGA(&u8g2, &u8g2_cb_r0); u8x8_InitDisplay(u8g2_GetU8x8(&u8g2)); u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); u8g2_SetFont(&u8g2, scrollosprites); u8g2_FirstPage(&u8g2); do { for( y = 0; y < map_height; y++ ) { for( x = 0; x < map_width; x++ ) { tile = map2[y][x]; /* check if there is a fg_tile, if so, use that tile instead */ for( i = 0; i < tile_cnt; i++ ) { if ( tile_list[i].item_index >= 0 ) { if ( tile_list[i].ascii == map[y][x] ) { tile = item_list[tile_list[i].item_index].fg_tile; } } } u8g2_DrawGlyph(&u8g2, x*16, y*16+16, tile); } } } while( u8g2_NextPage(&u8g2) ); tga_save(filename); }
int main(void) { tga_init(128,64); ucg_Init(&ucg, &ucg_dev_tga, ucg_ext_none, (ucg_com_fnptr)0); ucg_SetFontMode(&ucg, UCG_FONT_MODE_TRANSPARENT); ucg_SetColor(&ucg, 0, 0, 0, 0); ucg_DrawBox(&ucg, 0, 0, 128, 64); ucg_SetFont(&ucg, ucg_font_ncenB18_tf); ucg_SetColor(&ucg, 0, 0, 0, 255); ucg_DrawPixel(&ucg, 70,20); ucg_SetColor(&ucg, 0, 255, 0, 0); //ucg_SetFontPosBottom(&ucg); /* ucg_DrawGlyph(&ucg, 70, 20, 0, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 1, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 2, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 3, 'A'); ucg_SetColor(&ucg, 0, 255, 255, 255); vrule(&ucg, 30, 0, 20, 1); vrule(&ucg, 30, 0, 20, 0); */ //pos(&ucg, 70, 20, 0); //hrule(&ucg, 0, 20, 70, 1); //hrule(&ucg, 0, 20, 70, 0); ucg_SetColor(&ucg, 0, 255, 0, 0); ucg_SetColor(&ucg, 1, 0, 255, 0); ucg_SetColor(&ucg, 2, 255, 0, 255); ucg_SetColor(&ucg, 3, 0, 255, 255); ucg_DrawGradientLine(&ucg, 10, 40, 100, 0); ucg_DrawGradientBox(&ucg, 10, 43, 100, 20); tga_save("test.tga"); draw_pixel(&ucg); draw_hline(&ucg); draw_vline(&ucg); set_clip_range(&ucg); draw_text_baseline(&ucg); draw_text_bottom(&ucg); draw_text_top(&ucg); draw_text_center(&ucg); draw_text_ascent_descent(&ucg); draw_text_dir1(&ucg); draw_box(&ucg); draw_frame(&ucg); draw_rbox(&ucg); draw_rframe(&ucg); draw_gradient_box(&ucg); draw_gradient_line(&ucg); draw_disc(&ucg); draw_circle(&ucg); draw_triangle(&ucg); set_scale2x2(&ucg); set_font_mode_1(&ucg); set_font_mode_2(&ucg); solid_font_variants(&ucg); string_overwrite(&ucg, 1); string_overwrite(&ucg, 5); string_overwrite(&ucg, 10); return 0; }
int main(void) { int x, y; int k; int i; u8g2_SetupBuffer_TGA_LCD(&u8g2, &u8g2_cb_r0); u8x8_InitDisplay(u8g2_GetU8x8(&u8g2)); u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr); x = 50; y = 30+0; #ifdef U8G2_WITH_HVLINE_COUNT u8g2.hv_cnt = 0UL; #endif /* U8G2_WITH_HVLINE_COUNT */ /* u8g2_ClearBuffer(&u8g2); u8g2_SetFontDirection(&u8g2, 0); u8g2_DrawStr(&u8g2, x, y, "ABC"); u8g2_SetFontDirection(&u8g2, 1); u8g2_DrawStr(&u8g2, x, y, "abc"); u8g2_SetFontDirection(&u8g2, 2); u8g2_DrawStr(&u8g2, x, y, "abc"); u8g2_SetFontDirection(&u8g2, 3); u8g2_DrawStr(&u8g2, x, y, "abc"); u8g2_SendBuffer(&u8g2); */ u8g2_FirstPage(&u8g2); i = 0; do { u8g2_SetFontDirection(&u8g2, 0); u8g2_DrawStr(&u8g2, x, y, "ABC"); u8g2_SetFontDirection(&u8g2, 1); u8g2_DrawStr(&u8g2, x, y, "abc"); u8g2_SetFontDirection(&u8g2, 2); u8g2_DrawStr(&u8g2, x, y, "abc"); u8g2_SetFontDirection(&u8g2, 3); u8g2_DrawStr(&u8g2, x, y, "abc"); if ( i == 1 ) { u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0); u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0); u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0); u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0); } i++; } while( u8g2_NextPage(&u8g2) ); #ifdef U8G2_WITH_HVLINE_COUNT printf("hv cnt: %ld\n", u8g2.hv_cnt); #endif /* U8G2_WITH_HVLINE_COUNT */ tga_save("u8g2.tga"); return 0; }
int main(int argc, char **argv) { bf_t *bf_desc_font; bf_t *bf; char *bdf_filename = NULL; int is_verbose = 0; char *map_str ="*"; char *desc_font_str = ""; unsigned y; argv++; /* if ( *argv == NULL ) { help(); exit(1); } */ for(;;) { if ( *argv == NULL ) break; if ( is_arg(&argv, 'h') != 0 ) { help(); exit(1); } else if ( is_arg(&argv, 'v') != 0 ) { is_verbose = 1; } else if ( is_arg(&argv, 'a') != 0 ) { font_picture_extra_info = 1; } else if ( is_arg(&argv, 't') != 0 ) { font_picture_test_string = 1; } else if ( is_arg(&argv, 'r') != 0 ) { runtime_test = 1; } else if ( get_num_arg(&argv, 'b', &build_bbx_mode) != 0 ) { } else if ( get_num_arg(&argv, 'f', &font_format) != 0 ) { } else if ( get_num_arg(&argv, 'l', &left_margin) != 0 ) { } else if ( get_str_arg(&argv, 'd', &desc_font_str) != 0 ) { } else if ( get_str_arg(&argv, 'o', &c_filename) != 0 ) { } else if ( get_str_arg(&argv, 'n', &target_fontname) != 0 ) { } else if ( get_str_arg(&argv, 'm', &map_str) != 0 ) { } else { bdf_filename = *argv; argv++; } } if ( bdf_filename == NULL ) { help(); exit(1); } bf_desc_font = NULL; if ( desc_font_str[0] != '\0' ) { bf_desc_font = bf_OpenFromFile(desc_font_str, 0, BDF_BBX_MODE_MINIMAL, "*", 0); /* assume format 0 for description */ if ( bf_desc_font == NULL ) { exit(1); } } if ( font_format == 1 ) { build_bbx_mode = BDF_BBX_MODE_M8; /* issue the following log message later, when there is a valid bf object */ /* bf_Log(bf, "Font mode 1: BBX mode set to 3"); */ } bf = bf_OpenFromFile(bdf_filename, is_verbose, build_bbx_mode, map_str, font_format); if ( bf == NULL ) { exit(1); } if ( font_format == 1 ) { /* now generate the log message */ bf_Log(bf, "Note: For font format 1 BBX mode has been set to 3"); } if ( bf_desc_font != NULL ) { tga_init(1024, 600); y = tga_draw_font(0, bdf_filename, bf_desc_font, bf); if ( runtime_test != 0 ) { long i; clock_t c = clock(); fd_t fd; fd_init(&fd); fd_set_font(&fd, bf->target_data); for( i = 0; i < 10000; i++ ) fd_draw_string(&fd, left_margin, y, "Woven silk pyjamas exchanged for blue quartz."); bf_Log(bf, "Runtime test: %.2lf sec", (double)(clock()-c)/(double)CLOCKS_PER_SEC); } tga_save("bdf.tga"); } if ( c_filename != NULL ) { /* write the encoded data in bf->target_data */ if ( font_format == 0 ) { bf_WriteUCGCByFilename(bf, c_filename, target_fontname, " "); } else { bf_WriteU8G2CByFilename(bf, c_filename, target_fontname, " "); } } bf_Close(bf); return 0; }