From bd1b329029e010382344f26f8322055538b2fd70 Mon Sep 17 00:00:00 2001 From: tTh Date: Tue, 20 Sep 2022 11:21:41 +0200 Subject: [PATCH] add a test func for draw/rect paint funcs --- Lib/foo.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/Lib/foo.c b/Lib/foo.c index ef70caf..f9a919c 100644 --- a/Lib/foo.c +++ b/Lib/foo.c @@ -5,15 +5,69 @@ #include "../tthimage.h" +/* ============================== */ +int essai_show_t16x24( char *text) +{ +if (NULL != text) + Image_t16x24_essai("16x24thin", text, "16x24.tga"); +else + Image_t16x24_essai("16x24thin", "0123456789abcdef", "16x24.tga"); +return 0; +} +/* ============================== */ +int essai_draw_paint_rect(char *outga) +{ +Image_Desc *img; +Image_Rect rect; +int foo, x, y; + +fprintf(stderr, ">>> %s ( '%s' )\n", __func__, outga); + +rect.x = 8; rect.y = 8; +rect.w = 6; rect.h = 6; + +if (NULL==(img=Image_alloc(64, 32, 3))) { + abort(); + } + +for (x=0; xwidth; x+=2) { + for (y=0; yheight; y+=2) { + Image_plotRGB(img, x, y, 200, 200, 200); + } + } + +foo = Image_draw_rect(img, &rect, 192, 128, 64); +if (foo) { + fprintf(stderr, "%s: err %d draw rect\n", __func__, foo); + return foo; + } + +rect.x = 24; +foo = Image_paint_rect(img, &rect, 64, 128, 192); +if (foo) { + fprintf(stderr, "%s: err %d paint rect\n", __func__, foo); + return foo; + } + +foo = Image_TGA_save(outga, img, 0); +if (foo) { + fprintf(stderr, "%s: err %d save '%s'\n", __func__, foo, outga); + return foo; + } + +return OLL_KORRECT; +} +/* ============================== */ + int main(int argc, char *argv[]) { +int foo; + Image_print_version(2); Image_print_sizeof_structs("foo"); -if (2==argc) - Image_t16x24_essai("16x24thin", argv[1], "16x24.tga"); -else - Image_t16x24_essai("16x24thin", "0123456789abcdef", "16x24.tga"); +foo = essai_draw_paint_rect("foo.tga"); +fprintf(stderr, "essai draw rect --> %d\n", foo); return 0; }