diff options
author | miwi <miwi@FreeBSD.org> | 2011-11-10 10:24:37 +0800 |
---|---|---|
committer | miwi <miwi@FreeBSD.org> | 2011-11-10 10:24:37 +0800 |
commit | 604e0ef02dbdb46d80dcb6bda21a3f0368a21cc4 (patch) | |
tree | 27e242ebbd56697ffcc2378d2f9dff68c584955d /devel | |
parent | c253e3e68635175104a90b26b71ccd3a30f96cb6 (diff) | |
download | freebsd-ports-graphics-604e0ef02dbdb46d80dcb6bda21a3f0368a21cc4.tar.gz freebsd-ports-graphics-604e0ef02dbdb46d80dcb6bda21a3f0368a21cc4.tar.zst freebsd-ports-graphics-604e0ef02dbdb46d80dcb6bda21a3f0368a21cc4.zip |
A library that can be used for drawing images, circles, lines and test on
the LCD
WWW: http://g19linux.sourceforge.net/
PR: ports/156426
Submitted by: Armin Pirkovitsch <armin@frozen-zone.org>
Diffstat (limited to 'devel')
-rw-r--r-- | devel/Makefile | 1 | ||||
-rw-r--r-- | devel/libg19draw/Makefile | 30 | ||||
-rw-r--r-- | devel/libg19draw/distinfo | 2 | ||||
-rw-r--r-- | devel/libg19draw/files/patch-configure | 57 | ||||
-rw-r--r-- | devel/libg19draw/files/patch-libg19draw.c | 553 | ||||
-rw-r--r-- | devel/libg19draw/files/patch-libg19draw.h | 182 | ||||
-rw-r--r-- | devel/libg19draw/pkg-descr | 4 |
7 files changed, 829 insertions, 0 deletions
diff --git a/devel/Makefile b/devel/Makefile index d03961c1295..1d00ddff298 100644 --- a/devel/Makefile +++ b/devel/Makefile @@ -822,6 +822,7 @@ SUBDIR += libfreefare SUBDIR += libftdi SUBDIR += libg19 + SUBDIR += libg19draw SUBDIR += libgalago SUBDIR += libgamepad SUBDIR += libgconf-java diff --git a/devel/libg19draw/Makefile b/devel/libg19draw/Makefile new file mode 100644 index 00000000000..c020484adfe --- /dev/null +++ b/devel/libg19draw/Makefile @@ -0,0 +1,30 @@ +# New ports collection makefile for: libg19draw +# Date created: Apr 15 2011 +# Whom: Armin Pirkovitsch <armin@frozen-zone.org> +# +# $FreeBSD$ +# + +PORTNAME= libg19draw +PORTVERSION= 1.0.0 +CATEGORIES= devel +MASTER_SITES= SF/g19linux/${PORTNAME}/${PORTNAME}-${PORTVERSION} + +MAINTAINER= armin@frozen-zone.org +COMMENT= G19 draw library + +LIB_DEPENDS= g19.1:${PORTSDIR}/devel/libg19 \ + freetype.9:${PORTSDIR}/print/freetype2 + +CONFIGURE_ENV= LDFLAGS="-L${LOCALBASE}/lib -pthread" + +USE_LDCONFIG= yes +GNU_CONFIGURE= yes + +PLIST_FILES= include/libg19draw.h \ + lib/libg19draw.a \ + lib/libg19draw.la \ + lib/libg19draw.so \ + lib/libg19draw.so.1 + +.include <bsd.port.mk> diff --git a/devel/libg19draw/distinfo b/devel/libg19draw/distinfo new file mode 100644 index 00000000000..08854a02d80 --- /dev/null +++ b/devel/libg19draw/distinfo @@ -0,0 +1,2 @@ +SHA256 (libg19draw-1.0.0.tar.gz) = 6ac1205f97f59d9fd7ac3cf8af96e6559fec797300884fb5385cc7e594a3ca7f +SIZE (libg19draw-1.0.0.tar.gz) = 327873 diff --git a/devel/libg19draw/files/patch-configure b/devel/libg19draw/files/patch-configure new file mode 100644 index 00000000000..1d4922d5f59 --- /dev/null +++ b/devel/libg19draw/files/patch-configure @@ -0,0 +1,57 @@ +--- configure.orig 2010-04-11 05:19:11.000000000 +0200 ++++ configure 2011-04-16 08:44:40.000000000 +0200 +@@ -20199,9 +20199,9 @@ + fi + + +-{ $as_echo "$as_me:$LINENO: checking for g19_update_lcd_bmp in -lg19" >&5 +-$as_echo_n "checking for g19_update_lcd_bmp in -lg19... " >&6; } +-if test "${ac_cv_lib_g19_g19_update_lcd_bmp+set}" = set; then ++{ $as_echo "$as_me:$LINENO: checking for g19_update_lcd in -lg19" >&5 ++$as_echo_n "checking for g19_update_lcd in -lg19... " >&6; } ++if test "${ac_cv_lib_g19_g19_update_lcd+set}" = set; then + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +@@ -20219,11 +20219,11 @@ + #ifdef __cplusplus + extern "C" + #endif +-char g19_update_lcd_bmp (); ++char g19_update_lcd (); + int + main () + { +-return g19_update_lcd_bmp (); ++return g19_update_lcd (); + ; + return 0; + } +@@ -20249,12 +20249,12 @@ + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then +- ac_cv_lib_g19_g19_update_lcd_bmp=yes ++ ac_cv_lib_g19_g19_update_lcd=yes + else + $as_echo "$as_me: failed program was:" >&5 + sed 's/^/| /' conftest.$ac_ext >&5 + +- ac_cv_lib_g19_g19_update_lcd_bmp=no ++ ac_cv_lib_g19_g19_update_lcd=no + fi + + rm -rf conftest.dSYM +@@ -20262,9 +20262,9 @@ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_lib_save_LIBS + fi +-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_g19_g19_update_lcd_bmp" >&5 +-$as_echo "$ac_cv_lib_g19_g19_update_lcd_bmp" >&6; } +-if test "x$ac_cv_lib_g19_g19_update_lcd_bmp" = x""yes; then ++{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_g19_g19_update_lcd" >&5 ++$as_echo "$ac_cv_lib_g19_g19_update_lcd" >&6; } ++if test "x$ac_cv_lib_g19_g19_update_lcd" = x""yes; then + cat >>confdefs.h <<_ACEOF + #define HAVE_LIBG19 1 + _ACEOF diff --git a/devel/libg19draw/files/patch-libg19draw.c b/devel/libg19draw/files/patch-libg19draw.c new file mode 100644 index 00000000000..ddaf1d1389b --- /dev/null +++ b/devel/libg19draw/files/patch-libg19draw.c @@ -0,0 +1,553 @@ +--- libg19draw.c.orig 2010-04-11 03:29:42.000000000 +0200 ++++ libg19draw.c 2011-04-16 08:41:30.000000000 +0200 +@@ -21,22 +21,211 @@ + #include <stdlib.h> + #include <string.h> + +-#include "config.h" ++#include <config.h> + #include "libg19draw.h" + ++ + #ifdef FT2_SUPPORT ++ ++#include "libg19draw.h" ++ + #include <ft2build.h> + #include FT_FREETYPE_H + #include FT_BITMAP_H + +-static FT_Library ft_lib; +-static FT_Face ft_face; +-static int ft_width; +-static int ft_height; +-static int ft_space; +-static unsigned int ft_color; ++/** ++ * Creates a new G19Font ++ * ++ * @param ttf_path path to the ttf file ++ * @param width width of text ++ * @param height height of text ++ * @param space space between characters in pixels ++ * @param color an unsigned int that hold the color; G19Color() or G19ColorA() can be used ++ * ++ * @return pointer to a G19Font or NULL on error ++ **/ ++G19Font * g19_font_new(char * ttf_path, int width, int height, int space, unsigned int color) ++{ ++ G19Font * font = malloc(sizeof(G19Font)); ++ ++ if(FT_Init_FreeType(&font -> lib)) ++ return NULL; ++ ++ if(FT_New_Face(font -> lib, ttf_path, 0, &font -> face)) ++ { ++ FT_Done_FreeType(font -> lib); ++ return NULL; ++ } ++ ++ if(FT_Set_Pixel_Sizes(font -> face, width, height)) ++ { ++ FT_Done_Face(font -> face); ++ FT_Done_FreeType(font -> lib); ++ return NULL; ++ } ++ ++ font -> width = width; ++ font -> height = height; ++ font -> space = space; ++ font -> color = color; ++ ++ return font; ++} ++ ++/** ++ * Sets the character size on the G19Font ++ * ++ * @param font a pointer G19Font ++ * @param width width of text ++ * @param height height of text ++ **/ ++void g19_font_set_size(G19Font * font, int width, int height) ++{ ++ if(font == NULL) ++ return; ++ ++ FT_Set_Pixel_Sizes(font -> face, width, height); ++ ++ font -> width = width; ++ font -> height = height; ++} ++ ++/** ++ * Sets the character spacing on the G19Font ++ * ++ * @param font a pointer G19Font ++ * @param space between characters in pixels ++ **/ ++void g19_font_set_space(G19Font * font, int space) ++{ ++ if(font == NULL) ++ return; ++ ++ font -> space = space; ++} ++ ++/** ++ * Sets the color on the G19Font ++ * ++ * @param font a pointer G19Font ++ * @param color the color to set the text; G19Color() or G19ColorA() can be used ++ **/ ++void g19_font_set_color(G19Font * font, unsigned int color) ++{ ++ if(font == NULL) ++ return; ++ ++ font -> color = color; ++} ++ ++/** ++ * Draws text on the G19Draw with G19Font ++ * ++ * @param font a pointer G19Font ++ * @param draw a pointer G19Draw ++ * @param x x coordinate of the upper-left ++ * @param y y coordinate of the upper-left ++ * @param text pointer to an array of chars to be drawn ++ * ++ * @return the number of characters written or < 0 on error ++ **/ ++int g19_font_draw(G19Font * font, G19Draw * draw, int x, int y, char * text) ++{ ++ if((font == NULL) || (draw == NULL)) ++ return -1; ++ ++ if((font -> lib == NULL) || (font -> face == NULL)) ++ return -1; ++ ++ int res, i; ++ FT_GlyphSlot slot; ++ FT_UInt gi; ++ ++ slot = font -> face -> glyph; ++ ++ for(i = 0; i < strlen(text); i++) ++ { ++ gi = FT_Get_Char_Index(font -> face, text[i]); ++ ++ if(gi == 0) ++ continue; ++ ++ res = FT_Load_Char(font -> face, (FT_ULong) text[i], FT_LOAD_DEFAULT); ++ if(res) ++ continue; ++ ++ res = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL); ++ if(res) ++ continue; ++ ++ if(slot -> bitmap.width < 1) ++ { ++ x += (font -> width / 2); ++ continue; ++ } ++ ++ x += font -> space; ++ ++ if((x + slot -> bitmap.width) >= draw -> width) ++ break; ++ ++ int xx, yy; ++ unsigned char tc; ++ unsigned int bcolor, fcolor; ++ int r, g, b; ++ ++ for(yy = 0; yy < slot -> bitmap.rows; yy++) ++ { ++ for(xx = 0; xx < slot -> bitmap.width; xx++) ++ { ++ tc = slot -> bitmap.buffer[(yy * slot -> bitmap.width) + xx]; ++ ++ if(tc == 0) ++ continue; ++ ++ bcolor = g19_draw_get_pixel(draw, xx, yy); ++ ++ r = G19R(bcolor) + (((G19R(font -> color) - G19R(bcolor)) * tc) / 256); ++ g = G19G(bcolor) + (((G19G(font -> color) - G19G(bcolor)) * tc) / 256); ++ b = G19B(bcolor) + (((G19B(font -> color) - G19B(bcolor)) * tc) / 256); ++ ++ fcolor = G19Color(r, g, b); ++ ++ g19_draw_set_pixel(draw, slot -> bitmap_left + xx + x, ++ (font -> height - slot -> bitmap_top) + yy + y, fcolor); ++ } ++ } ++ ++ x += slot -> bitmap.width; ++ } ++ ++ return i; ++} ++ ++/** ++ * Frees a G19Font ++ * ++ * @param font a pointer G19Font ++ **/ ++void g19_font_free(G19Font * font) ++{ ++ if(font == NULL) ++ return; ++ ++ if(font -> face != NULL) ++ FT_Done_Face(font -> face); ++ ++ if(font -> lib != NULL) ++ FT_Done_FreeType(font -> lib); ++ ++ free(font); ++} ++ + #endif + ++ ++ ++ + /** + * Creates a new G19Draw + * +@@ -49,13 +238,13 @@ + { + G19Draw * draw; + +- draw = (G19Draw *) malloc(sizeof(G19Draw)); ++ draw = malloc(sizeof(G19Draw)); + + draw -> width = width; + draw -> height = height; + draw -> size = width * height * 4; + +- draw -> data = (unsigned char *) malloc(draw -> size); ++ draw -> data = malloc(draw -> size); + memset(draw -> data, 0x00, draw -> size); + + return draw; +@@ -143,9 +332,9 @@ + + fseek(file, doff, SEEK_SET); + +- for(x = 0; x < width; x++) ++ for(y = height - 1; y > 0; y--) + { +- for(y = 0; y < height; y++) ++ for(x = 0; x < width; x++) + { + if(bits == 24) + { +@@ -158,7 +347,7 @@ + color = G19ColorA(buffer[2], buffer[1], buffer[0], buffer[3]); + } + +- g19_draw_set_pixel(draw, y + (width - height), ((width + (height - width)) - 1) - x, color); ++ g19_draw_set_pixel(draw, x, y, color); + } + } + +@@ -184,6 +373,98 @@ + } + + /** ++ * Save a G19Draw to an 24-bit bitmap ++ * ++ * @param draw pointer to a G19Draw ++ * @param path path to save the image to ++ * ++ * @return 0 on success; non-zero on error ++ **/ ++int g19_draw_to_bmp(G19Draw * draw, char * path) ++{ ++ FILE * fp; ++ unsigned char * bmp; ++ int data_size, bmp_size; ++ int d ,x, y; ++ unsigned int color; ++ ++ fp = fopen(path, "wb"); ++ if(fp == NULL) ++ return -1; ++ ++ data_size = (draw -> width * draw -> height) * 4; ++ bmp_size = data_size + 54; ++ ++ bmp = malloc(bmp_size); ++ memset(bmp, 0, bmp_size); ++ ++ bmp[0x0] = 0x42; ++ bmp[0x1] = 0x4d; ++ bmp[0xa] = 0x36; ++ bmp[0xe] = 0x28; ++ bmp[0x1a] = 0x1; ++ bmp[0x1c] = 0x20; ++ ++ d = 2835; ++ ++ memcpy(bmp + 0x2, &bmp_size, 4); ++ memcpy(bmp + 0x12, &draw -> width, 4); ++ memcpy(bmp + 0x16, &draw -> height, 4); ++ memcpy(bmp + 0x22, &data_size, 4); ++ memcpy(bmp + 0x26, &d, 4); ++ memcpy(bmp + 0x2a, &d, 4); ++ ++ d = 0; ++ for(y = draw -> height - 1; y > 0; y--) ++ { ++ for(x = 0; x < draw -> width; x++) ++ { ++ color = g19_draw_get_pixel(draw, x, y); ++ color = G19ColorA(G19B(color), G19G(color), ++ G19R(color), 0xff); ++ ++ memcpy(bmp + ((d * 4) + 0x36), &color, 4); ++ d++; ++ } ++ } ++ ++ fwrite(bmp, 1, bmp_size, fp); ++ free(bmp); ++ ++ fclose(fp); ++ ++ return 0; ++} ++ ++/** ++ * Resizes a G19Draw ++ * ++ * @param width width in pixels to resize to ++ * @param height height in pixels to resize to ++ * @param color the base color of the new image; G19Color() or G19ColorA() can be used ++ * @param free_old free the allocated memory of the old old G19Draw; 0 for no, 1 for yes ++ * ++ * @return a pointer to the new G19Draw or NULL on error ++ **/ ++G19Draw * g19_draw_resize(G19Draw * draw, int width, int height, unsigned int color, int free_old) ++{ ++ if(draw == NULL) ++ return NULL; ++ ++ if((width < 1) || (height < 1)) ++ return NULL; ++ ++ G19Draw * resize = g19_draw_new(width, height); ++ g19_draw_fill(resize, color); ++ g19_draw_insert(resize, draw, 0, 0); ++ ++ if(free_old) ++ g19_draw_free(draw); ++ ++ return resize; ++} ++ ++/** + * Insert a G19Draw onto another G19Draw + * + * @param draw pointer to the destination G19Draw +@@ -242,7 +523,7 @@ + int x, y; + int dd, id; + unsigned char d1[4], d2[4]; +- int r, g, b; ++ unsigned char r, g, b; + unsigned int color; + + ex = ((ix + idraw -> width) < draw -> width) ? idraw -> width : (draw -> width - ix); +@@ -378,7 +659,7 @@ + + err = dx / 2; + y = y1; +- ystep = (y1 < y2) ? 1 : 0; ++ ystep = (y1 < y2) ? 1 : -1; + + for(x = x1; x < x2; x++) + { +@@ -388,7 +669,7 @@ + g19_draw_set_pixel(draw, x, y, color); + + err = err - dy; +- if(!err) ++ if(err < 0) + { + y = y + ystep; + err = err + dx; +@@ -417,7 +698,7 @@ + g19_draw_line(draw, left, top, right, top, color); + g19_draw_line(draw, left, bottom, right, bottom, color); + g19_draw_line(draw, left, top, left, bottom, color); +- g19_draw_line(draw, right, top, right, bottom, color); ++ g19_draw_line(draw, right, top, right, bottom + 1, color); + + return; + } +@@ -494,159 +775,3 @@ + } + + } +- +-/** +- * Draws a slot from FreeType on the G19Draw +- * +- * @param draw a pointer G19Draw +- * @param fslot G19FontSlot that holds the FreeType slot data +- **/ +-void g19_draw_ft_slot(G19Draw * draw, G19FontSlot * fslot, int x, int y) +-{ +- int xx, yy; +- unsigned char tc; +- unsigned int fcolor; +- +- if(draw == NULL) +- return; +- +- G19FontBitmap * bitmap = fslot -> bitmap; +- +- G19Draw * tdraw = g19_draw_new(fslot -> width, fslot -> bitmap_top + fslot -> height); +- g19_draw_fill(tdraw, G19ColorA(0, 0, 0, 0)); +- +- if(tdraw == NULL) +- return; +- +- for(yy = 0; yy < bitmap -> rows; yy++) +- { +- for(xx = 0; xx < bitmap -> width; xx++) +- { +- tc = bitmap -> buffer[(yy * bitmap -> width) + xx]; +- +- if(tc == 0) +- continue; +- +- fcolor = G19ColorA(G19R(fslot -> color), G19G(fslot -> color), +- G19B(fslot -> color), (256 + tc)); +- +- g19_draw_set_pixel(tdraw, fslot -> bitmap_left + xx, (fslot -> height - fslot -> bitmap_top) + yy, fcolor); +- } +- } +- +- g19_draw_insert_ab(draw, tdraw, x, y, -1); +- g19_draw_free(tdraw); +-} +- +-#ifdef FT2_SUPPORT +- +-/** +- * Sets the font for drawing +- * +- * @param ttf_path path to the ttf file +- * @param width width of text +- * @param height height of text +- * @param space space between chars in pixels +- * @param color an unsigned int that hold the color; G19Color() or G19ColorA() can be used +- * +- * @return non zero on failure +- **/ +-int g19_draw_set_font(char * ttf_path, int width, int height, int space, unsigned int color) +-{ +- int res = FT_Init_FreeType(&ft_lib); +- if(res) +- return res; +- +- res = FT_New_Face(ft_lib, ttf_path, 0, &ft_face); +- if(res) +- return res; +- +- res = FT_Set_Pixel_Sizes(ft_face, width, height); +- if(res) +- return res; +- +- ft_width = width; +- ft_height = height; +- ft_space = space; +- ft_color = color; +- +- if(space < 0) +- space = 0; +- +- return 0; +-} +- +-/** +- * Draws text on the G19Draw +- * Make sure you have executed g19_draw_set_font +- * +- * @param draw a pointer G19Draw +- * @param x x coordinate of the upper-left +- * @param y y coordinate of the upper-left +- * @param text pointer to an array of chars to be drawn +- * +- * @return non zero on failure +- **/ +-int g19_draw_text(G19Draw * draw, int x, int y, char * text) +-{ +- int res, i; +- FT_GlyphSlot slot; +- FT_UInt gi; +- +- if((ft_lib == NULL) || (ft_face == NULL)) +- return -1; +- +- slot = ft_face -> glyph; +- +- for(i = 0; i < strlen(text); i++) +- { +- gi = FT_Get_Char_Index(ft_face, text[i]); +- +- if(gi == 0) +- continue; +- +- res = FT_Load_Char(ft_face, (FT_ULong) text[i], FT_LOAD_DEFAULT); +- if(res) +- continue; +- +- res = FT_Render_Glyph(ft_face -> glyph, FT_RENDER_MODE_NORMAL); +- if(res) +- continue; +- +- if(slot -> bitmap.width < 1) +- { +- x += ft_width; +- continue; +- } +- +- x += ft_space; +- +- G19FontSlot fslot; +- fslot.width = ft_width; +- fslot.height = ft_height; +- fslot.bitmap_left = slot -> bitmap_left; +- fslot.bitmap_top = slot -> bitmap_top; +- fslot.color = ft_color; +- fslot.bitmap = (G19FontBitmap *) &slot -> bitmap; +- +- g19_draw_ft_slot(draw, &fslot, x, y); +- +- x += slot -> bitmap.width; +- } +- +- return 0; +-} +- +-/** +- * Closes the FreeType library and font handle from g19_draw_set_font() +- **/ +-void g19_draw_close_font(void) +-{ +- if(ft_face != NULL) +- FT_Done_Face(ft_face); +- +- if(ft_lib != NULL) +- FT_Done_FreeType(ft_lib); +-} +- +-#endif diff --git a/devel/libg19draw/files/patch-libg19draw.h b/devel/libg19draw/files/patch-libg19draw.h new file mode 100644 index 00000000000..93ecaed98da --- /dev/null +++ b/devel/libg19draw/files/patch-libg19draw.h @@ -0,0 +1,182 @@ +--- libg19draw.h.orig 2010-04-11 04:51:51.000000000 +0200 ++++ libg19draw.h 2011-04-16 08:26:10.000000000 +0200 +@@ -19,12 +19,26 @@ + #ifndef LIBG19DRAW_H + #define LIBG19DRAW_H + ++#include <string.h> ++ ++#ifdef FT2_SUPPORT ++ ++#include <ft2build.h> ++#include FT_FREETYPE_H ++#include FT_BITMAP_H ++ ++#endif ++ + #ifdef __cplusplus + extern "C" + { + #endif + +-#define LIBG19DRAW_VERSION "1.0.0" ++#define LIBG19DRAW_VERSION_MAJOR 1 ++#define LIBG19DRAW_VERSION_MINOR 1 ++#define LIBG19DRAW_VERSION_MICRO 0 ++ ++#define LIBG19DRAW_VERSION "1.1.0" + + #define G19_WIDTH 320 + #define G19_HEIGHT 240 +@@ -44,30 +58,25 @@ + { + int width; + int height; +- int size; ++ size_t size; + unsigned char * data; + } + G19Draw; + +-typedef struct +-{ +- int rows; +- int width; +- int pitch; +- unsigned char * buffer; +-} +-G19FontBitmap; ++#ifdef FT2_SUPPORT + + typedef struct + { ++ FT_Library lib; ++ FT_Face face; + int width; + int height; +- int bitmap_left; +- int bitmap_top; ++ int space; + unsigned int color; +- G19FontBitmap * bitmap; + } +-G19FontSlot; ++G19Font; ++ ++#endif + + /** + * Creates a new G19Draw +@@ -99,6 +108,28 @@ + void g19_draw_free(G19Draw * draw); + + /** ++ * Save a G19Draw to an 24-bit bitmap ++ * ++ * @param draw pointer to a G19Draw ++ * @param path path to save the image to ++ * ++ * @return 0 on success; non-zero on error ++ **/ ++int g19_draw_to_bmp(G19Draw * draw, char * path); ++ ++/** ++ * Resizes a G19Draw ++ * ++ * @param width width in pixels to resize to ++ * @param height height in pixels to resize to ++ * @param color the base color of the new image; G19Color() or G19ColorA() can be used ++ * @param free_old free the allocated memory of the old old G19Draw; 0 for no, 1 for yes ++ * ++ * @return a pointer to the new G19Draw or NULL on error ++ **/ ++G19Draw * g19_draw_resize(G19Draw * draw, int width, int height, unsigned int color, int free_old); ++ ++/** + * Insert a G19Draw onto another G19Draw + * + * @param draw pointer to the destination G19Draw +@@ -185,18 +216,11 @@ + **/ + void g19_draw_circle(G19Draw * draw, int cx, int cy, int cr, int fill, unsigned int color); + +-/** +- * Draws a slot from FreeType on the G19Draw +- * +- * @param draw a pointer G19Draw +- * @param fslot G19FontSlot that holds the FreeType slot data +- **/ +-void g19_draw_ft_slot(G19Draw * draw, G19FontSlot * fslot, int x, int y); + + #ifdef FT2_SUPPORT + + /** +- * Sets the font for drawing ++ * Creates a new G19Font + * + * @param ttf_path path to the ttf file + * @param width width of text +@@ -204,27 +228,55 @@ + * @param space space between chars in pixels + * @param color an unsigned int that hold the color; G19Color() or G19ColorA() can be used + * +- * @return non zero on failure ++ * @return pointer to a G19Font or NULL on error ++ **/ ++G19Font * g19_font_new(char * ttf_path, int width, int height, int space, unsigned int color); ++ ++/** ++ * Sets the character size on the G19Font ++ * ++ * @param font a pointer G19Font ++ * @param width width of text ++ * @param height height of text ++ **/ ++void g19_font_set_size(G19Font * font, int width, int height); ++ ++/** ++ * Sets the character spacing on the G19Font ++ * ++ * @param font a pointer G19Font ++ * @param space between characters in pixels + **/ +-int g19_draw_set_font(char * ttf_path, int width, int height, int space, unsigned int color); ++void g19_font_set_space(G19Font * font, int space); + + /** +- * Draws text on the G19Draw +- * Make sure you have executed g19_draw_set_font ++ * Sets the color on the G19Font + * ++ * @param font a pointer G19Font ++ * @param color the color to set the text; G19Color() or G19ColorA() can be used ++ **/ ++void g19_font_set_color(G19Font * font, unsigned int color); ++ ++/** ++ * Draws text on the G19Draw with G19Font ++ * ++ * @param font a pointer G19Font + * @param draw a pointer G19Draw + * @param x x coordinate of the upper-left + * @param y y coordinate of the upper-left + * @param text pointer to an array of chars to be drawn + * +- * @return non zero on failure ++ * @return the number of characters written or < 0 on error + **/ +-int g19_draw_text(G19Draw * draw, int x, int y, char * text); ++int g19_font_draw(G19Font * font, G19Draw * draw, int x, int y, char * text); ++ + + /** +- * Closes the FreeType library and font handle from g19_draw_set_font() ++ * Frees a G19Font ++ * ++ * @param font a pointer G19Font + **/ +-void g19_draw_close_font(void); ++void g19_font_free(G19Font * font); + + #endif + diff --git a/devel/libg19draw/pkg-descr b/devel/libg19draw/pkg-descr new file mode 100644 index 00000000000..36542be8bbc --- /dev/null +++ b/devel/libg19draw/pkg-descr @@ -0,0 +1,4 @@ +A library that can be used for drawing images, circles, lines and test on +the LCD + +WWW: http://g19linux.sourceforge.net/ |