This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 8c1e7985a175989be85334919aac053c290933a3 (commit) from 8bb3b493c0a89be19912de69a505e78708f98b19 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/8c1e7985a175989be85334919aac053c29093...
commit 8c1e7985a175989be85334919aac053c290933a3 Author: Cyril Hrubis metan@ucw.cz Date: Sat Apr 7 19:31:15 2012 +0200
demos: Add simple ttf font demo.
diff --git a/demos/Makefile b/demos/Makefile index 3198465..1d61deb 100644 --- a/demos/Makefile +++ b/demos/Makefile @@ -1,3 +1,3 @@ TOPDIR=.. -SUBDIRS=grinder spiv particle +SUBDIRS=grinder spiv particle ttf2img include $(TOPDIR)/post.mk diff --git a/demos/ttf2img/Makefile b/demos/ttf2img/Makefile new file mode 100644 index 0000000..aab67a7 --- /dev/null +++ b/demos/ttf2img/Makefile @@ -0,0 +1,12 @@ +TOPDIR=../.. + +CSOURCES=$(shell echo *.c) + +INCLUDE= +LDLIBS+=-lGP -L$(TOPDIR)/build/ + +APPS=ttf2img + +include $(TOPDIR)/pre.mk +include $(TOPDIR)/app.mk +include $(TOPDIR)/post.mk diff --git a/demos/ttf2img/runtest.sh b/demos/ttf2img/runtest.sh new file mode 100755 index 0000000..0794707 --- /dev/null +++ b/demos/ttf2img/runtest.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Run dynamically linked test. +# + +PROG="$1" +shift + +LD_LIBRARY_PATH=../../build/ ./$PROG "$@" diff --git a/demos/ttf2img/ttf2img.c b/demos/ttf2img/ttf2img.c new file mode 100644 index 0000000..0dea1fe --- /dev/null +++ b/demos/ttf2img/ttf2img.c @@ -0,0 +1,96 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim 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 GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + + /* + + Uses gfxprim to render small image with defined string. + + */ + +#include <GP.h> + +static const char help[] = { + "usage: ttf2img -f font.ttf -i file.png -s string [-d debug_level]n", +}; + +static void print_help(int i) +{ + fputs(help, stderr); + exit(i); +} + +int main(int argc, char *argv[]) +{ + const char *font_path = NULL; + const char *img_path = NULL; + const char *string = "Foo Bar!"; + int opt, debug_level = 0; + int img_w = 400, img_h = 100; + + while ((opt = getopt(argc, argv, "d:f:i:s:")) != -1) { + switch (opt) { + case 'f': + font_path = optarg; + break; + case 'i': + img_path = optarg; + break; + case 'd': + debug_level = atoi(optarg); + break; + case 'h': + print_help(0); + break; + case 's': + string = optarg; + break; + default: + fprintf(stderr, "Invalid paramter '%c'n", opt); + print_help(1); + } + } + + if (font_path == NULL || img_path == NULL) + print_help(1); + + GP_SetDebugLevel(debug_level); + + GP_Context *context = GP_ContextAlloc(img_w, img_h, GP_PIXEL_RGB888); + + GP_Pixel black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); + GP_Pixel white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); + + GP_Fill(context, white_pixel); + + GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; + + style.font = GP_FontFaceLoad(font_path, 27, 0); + + GP_Text(context, &style, img_w/2, img_h/2, GP_ALIGN_CENTER|GP_VALIGN_CENTER, + black_pixel, white_pixel, string); + + GP_SavePNG(img_path, context, NULL); + + GP_ContextFree(context); + + return 0; +}
-----------------------------------------------------------------------
Summary of changes: demos/Makefile | 2 +- demos/{grinder => ttf2img}/Makefile | 6 +- demos/{particle => ttf2img}/runtest.sh | 0 demos/{particle/space.h => ttf2img/ttf2img.c} | 94 +++++++++++++++---------- 4 files changed, 60 insertions(+), 42 deletions(-) copy demos/{grinder => ttf2img}/Makefile (70%) copy demos/{particle => ttf2img}/runtest.sh (100%) copy demos/{particle/space.h => ttf2img/ttf2img.c} (54%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.