ports/156426: New ports: devel/libg19, devel/libg19draw - libs to help using the Logitech G19 keyboard

Armin Pirkovitsch armin at frozen-zone.org
Sat Apr 16 08:20:14 UTC 2011


The following reply was made to PR ports/156426; it has been noted by GNATS.

From: Armin Pirkovitsch <armin at frozen-zone.org>
To: bug-followup at FreeBSD.org
Cc:  
Subject: Re: ports/156426: New ports: devel/libg19,	devel/libg19draw - libs
 to help using the Logitech G19 keyboard
Date: Sat, 16 Apr 2011 10:07:19 +0200

 This is a multi-part message in MIME format.
 --------------000904040502090806090507
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 After playing a little with those libs i noticed that some features do 
 not work properly...
 The attached shar includes patches to the latest git versions which work 
 so far.
 
 --------------000904040502090806090507
 Content-Type: text/plain;
  name="libg19-2.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="libg19-2.txt"
 
 # This is a shell archive.  Save it in a file, remove anything before
 # this line, and then unpack it by entering "sh file".  Note, it may
 # create directories; files and directories will be owned by you and
 # have default permissions.
 #
 # This archive contains:
 #
 #	devel/libg19
 #	devel/libg19/Makefile
 #	devel/libg19/distinfo
 #	devel/libg19/files
 #	devel/libg19/files/patch-configure
 #	devel/libg19/files/patch-libg19.c
 #	devel/libg19/files/patch-libg19.h
 #	devel/libg19/pkg-descr
 #	devel/libg19draw
 #	devel/libg19draw/Makefile
 #	devel/libg19draw/distinfo
 #	devel/libg19draw/files
 #	devel/libg19draw/files/patch-libg19draw.c
 #	devel/libg19draw/files/patch-libg19draw.h
 #	devel/libg19draw/files/patch-configure
 #	devel/libg19draw/pkg-descr
 #
 echo c - devel/libg19
 mkdir -p devel/libg19 > /dev/null 2>&1
 echo x - devel/libg19/Makefile
 sed 's/^X//' >devel/libg19/Makefile << '2c5994982a3f0f89081d3c511a15ae9b'
 X# New ports collection makefile for:	libg19
 X# Date created:				Apr 15 2011
 X# Whom:					Armin Pirkovitsch <armin at frozen-zone.org>
 X#
 X# $FreeBSD$
 X#
 X
 XPORTNAME=	libg19
 XPORTVERSION=	1.1.1
 XCATEGORIES=	devel
 XMASTER_SITES=	SF/g19linux/${PORTNAME}/${PORTNAME}-${PORTVERSION}
 X
 XMAINTAINER=	armin at frozen-zone.org
 XCOMMENT=	G19 library
 X
 XUSE_LDCONFIG=	yes
 XGNU_CONFIGURE=	yes
 X
 XPLIST_FILES=	include/libg19.h \
 X		lib/libg19.a \
 X		lib/libg19.la \
 X		lib/libg19.so \
 X		lib/libg19.so.1
 X
 X.include <bsd.port.pre.mk>
 X
 X.if ${OSVERSION} < 800069
 XBROKEN=	libusb 1.0 or newer required.
 X.endif
 X
 X.include <bsd.port.post.mk>
 2c5994982a3f0f89081d3c511a15ae9b
 echo x - devel/libg19/distinfo
 sed 's/^X//' >devel/libg19/distinfo << '0e399fc4ad0a712901328737522aa851'
 XSHA256 (libg19-1.1.1.tar.gz) = 98a27713ad1a02672aeded138f1fbc2a90d9206385fefbdbb74224cfdf5f240d
 XSIZE (libg19-1.1.1.tar.gz) = 329962
 0e399fc4ad0a712901328737522aa851
 echo c - devel/libg19/files
 mkdir -p devel/libg19/files > /dev/null 2>&1
 echo x - devel/libg19/files/patch-configure
 sed 's/^X//' >devel/libg19/files/patch-configure << 'd87243feb43a27832d43e8a1fa97e762'
 X--- configure.orig	2011-04-15 10:36:10.000000000 +0200
 X+++ configure	2011-04-15 15:27:11.000000000 +0200
 X@@ -20067,35 +20067,11 @@
 X 
 X if test -n "$libg19_CFLAGS"; then
 X     pkg_cv_libg19_CFLAGS="$libg19_CFLAGS"
 X- elif test -n "$PKG_CONFIG"; then
 X-    if test -n "$PKG_CONFIG" && \
 X-    { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\"") >&5
 X-  ($PKG_CONFIG --exists --print-errors "libusb-1.0") 2>&5
 X-  ac_status=$?
 X-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 X-  (exit $ac_status); }; then
 X-  pkg_cv_libg19_CFLAGS=`$PKG_CONFIG --cflags "libusb-1.0" 2>/dev/null`
 X-else
 X-  pkg_failed=yes
 X-fi
 X- else
 X-    pkg_failed=untried
 X fi
 X if test -n "$libg19_LIBS"; then
 X     pkg_cv_libg19_LIBS="$libg19_LIBS"
 X- elif test -n "$PKG_CONFIG"; then
 X-    if test -n "$PKG_CONFIG" && \
 X-    { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\"") >&5
 X-  ($PKG_CONFIG --exists --print-errors "libusb-1.0") 2>&5
 X-  ac_status=$?
 X-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
 X-  (exit $ac_status); }; then
 X-  pkg_cv_libg19_LIBS=`$PKG_CONFIG --libs "libusb-1.0" 2>/dev/null`
 X else
 X-  pkg_failed=yes
 X-fi
 X- else
 X-    pkg_failed=untried
 X+  pkg_cv_libg19_LIBS="-lusb"
 X fi
 X 
 X 
 d87243feb43a27832d43e8a1fa97e762
 echo x - devel/libg19/files/patch-libg19.c
 sed 's/^X//' >devel/libg19/files/patch-libg19.c << '8bd681bee17f21fa31823ec0d51b3751'
 X--- libg19.c.orig	2010-04-13 04:13:54.000000000 +0200
 X+++ libg19.c	2011-04-16 08:25:58.000000000 +0200
 X@@ -20,6 +20,7 @@
 X #include <libusb.h>
 X #include <pthread.h>
 X #include <stdio.h>
 X+#include <stdlib.h>
 X #include <string.h>
 X #include <unistd.h>
 X 
 X@@ -353,52 +354,54 @@
 X }
 X 
 X /**
 X- * Sends raw data to the lcd without formatting
 X+ * Sends the data to screen
 X  * 
 X  * @param data pointer to the screen data
 X- * @param len amount of data to be written in bytes
 X+ * @param size size of the data to be written in bytes
 X+ * @param flags options for the function to use for updating
 X  **/
 X-void g19_update_lcd(unsigned char * data, int len)
 X+void g19_update_lcd(unsigned char * data, size_t size, unsigned int flags)
 X {
 X-	struct libusb_transfer * lcd_transfer = libusb_alloc_transfer(0);
 X-	lcd_transfer -> flags = LIBUSB_TRANSFER_FREE_TRANSFER;
 X-	
 X-	libusb_fill_bulk_transfer(lcd_transfer, g19_devh, 0x02, data, len, NULL, NULL, 0);
 X-	libusb_submit_transfer(lcd_transfer);
 X-}
 X-
 X-/**
 X- * Prepends the header data to the screen data
 X- * Formats the bitmap data
 X- * Writes the result to the screen
 X- * 
 X- * @param data pointer to the bitmap data
 X- * @param len amount of data to be written in bytes
 X- **/
 X-void g19_update_lcd_bmp(unsigned char * data, int len)
 X-{
 X-	unsigned char bits[G19_BMP_SIZE];
 X-	
 X-	if(g19_devh == NULL)
 X+	if((g19_devh == NULL) || (size < 1))
 X 		return;
 X 	
 X-	memset(&bits, 0x00, sizeof(bits));
 X-	memcpy(&bits, &hdata, sizeof(hdata));
 X+	struct libusb_transfer * lcd_transfer;
 X+	size_t bsize = G19_BMP_SIZE;
 X+	unsigned char * bits = malloc(bsize);
 X 	
 X+	lcd_transfer = libusb_alloc_transfer(0);
 X+	lcd_transfer -> flags = LIBUSB_TRANSFER_FREE_TRANSFER;
 X 	
 X-	int i, d;
 X-	unsigned int color;
 X+	memset(bits, 0x00, bsize);
 X 	
 X-	for(i = sizeof(hdata); (i < G19_BMP_SIZE) && (d < len); i += 2, d += 4)
 X+	if((flags & G19_PREPEND_HDATA) || (flags & G19_DATA_TYPE_BMP))
 X 	{
 X-		color = (data[d] / 8) << 11;
 X-		color |= (data[d + 1] / 4) << 5;
 X-		color |= data[d + 2] / 8;
 X+		lcd_transfer -> flags |= LIBUSB_TRANSFER_FREE_BUFFER;
 X+		memcpy(bits, hdata, sizeof(hdata));
 X+		
 X+		if(flags & G19_DATA_TYPE_BMP)
 X+		{
 X+			int i, d;
 X+			unsigned int color;
 X+			
 X+			for(i = sizeof(hdata), d = 0; (i < bsize) && (d < size); i += 2, d += 4)
 X+			{
 X+				color = (data[d] / 8) << 11;
 X+				color |= (data[d + 1] / 4) << 5;
 X+				color |= data[d + 2] / 8;
 X+				
 X+				memcpy(bits + i, &color, 2);
 X+			}
 X+		}
 X+		else if(flags & G19_PREPEND_HDATA)
 X+			memcpy(bits + sizeof(hdata), data, ((size + sizeof(hdata)) > bsize) ? (bsize - sizeof(hdata)) : size);
 X 		
 X-		memcpy(bits + i, &color, 2);
 X+		libusb_fill_bulk_transfer(lcd_transfer, g19_devh, 0x02, bits, bsize, NULL, NULL, 0);
 X 	}
 X+	else
 X+		libusb_fill_bulk_transfer(lcd_transfer, g19_devh, 0x02, data, size, NULL, NULL, 0);
 X 	
 X-	g19_update_lcd(bits, G19_BMP_SIZE);
 X+	libusb_submit_transfer(lcd_transfer);
 X }
 X 
 X /**
 X@@ -410,7 +413,7 @@
 X  * 
 X  * @return non zero on error
 X  **/
 X-int g19_set_backlight(int r, int g, int b)
 X+int g19_set_backlight(unsigned char r, unsigned char g, unsigned char b)
 X {
 X 	if(g19_devh == NULL)
 X 		return -1;
 8bd681bee17f21fa31823ec0d51b3751
 echo x - devel/libg19/files/patch-libg19.h
 sed 's/^X//' >devel/libg19/files/patch-libg19.h << 'd354f61b3062f202f709c6ad42cd32a9'
 X--- libg19.h.orig	2010-04-12 21:56:18.000000000 +0200
 X+++ libg19.h	2011-04-16 08:25:58.000000000 +0200
 X@@ -20,15 +20,21 @@
 X #define G19_H
 X 
 X #include <stdint.h>
 X+#include <string.h>
 X 
 X #ifdef __cplusplus
 X extern "C"
 X {
 X #endif
 X 
 X-#define LIBG19_VERSION "1.1.1"
 X+#define LIBG19_VERSION_MAJOR	1
 X+#define LIBG19_VERSION_MINOR	2
 X+#define LIBG19_VERSION_MICRO	0
 X+
 X+#define LIBG19_VERSION			"1.2.0"
 X 
 X #define G19_BMP_SIZE	154112
 X+#define G19_BMP_DSIZE	153600
 X 
 X typedef struct
 X {
 X@@ -38,7 +44,32 @@
 X }
 X G19Device;
 X 
 X-enum
 X+enum G19UpdateFlags
 X+{
 X+	/*
 X+	 * Flags the screen to be
 X+	 * used and as of right now
 X+	 * there is only one which is
 X+	 * the G19.
 X+	 */
 X+	G19_SCREEN_DEFAULT	= 1 << 0,
 X+	
 X+	/* Flags to prepend header data */
 X+	G19_PREPEND_HDATA	= 1 << 1,
 X+	
 X+	/* Flags not to parse the data
 X+	 * and format it
 X+	 */
 X+	G19_DATA_TYPE_RAW	= 1 << 2,
 X+	
 X+	/* Flags to format a bitmap with
 X+	 * with just bitmap data that has
 X+	 * 4 bytes per pixel. (RGBA)
 X+	 */
 X+	G19_DATA_TYPE_BMP	= 1 << 3
 X+};
 X+
 X+enum G19Keys
 X {
 X 	G19_KEY_G1			= 1 << 0,
 X 	G19_KEY_G2			= 1 << 1,
 X@@ -104,19 +135,9 @@
 X  * Sends raw data to the lcd without formatting
 X  * 
 X  * @param data pointer to the screen data
 X- * @param len amount of data to be written in bytes
 X- **/
 X-void g19_update_lcd(unsigned char * data, int len);
 X-
 X-/**
 X- * Prepends the header data to the screen data
 X- * Formats the bitmap data
 X- * Writes the result to the screen
 X- * 
 X- * @param data pointer to the bitmap data
 X- * @param len amount of data to be written in bytes
 X+ * @param size size of the data to be written in bytes
 X  **/
 X-void g19_update_lcd_bmp(unsigned char * data, int len);
 X+void g19_update_lcd(unsigned char * data, size_t size, unsigned int flags);
 X 
 X /**
 X  * Sets the backlighting color
 X@@ -127,7 +148,7 @@
 X  * 
 X  * @return non zero on error
 X  **/
 X-int g19_set_backlight(int r, int g, int b);
 X+int g19_set_backlight(unsigned char r, unsigned char g, unsigned char b);
 X 
 X /**
 X  * Sets the M-Key lights
 d354f61b3062f202f709c6ad42cd32a9
 echo x - devel/libg19/pkg-descr
 sed 's/^X//' >devel/libg19/pkg-descr << '5262e518df8506a639977fe90f58bab5'
 XA library that handles the USB interfacing with the G19
 X
 XWWW: http://g19linux.sourceforge.net/
 5262e518df8506a639977fe90f58bab5
 echo c - devel/libg19draw
 mkdir -p devel/libg19draw > /dev/null 2>&1
 echo x - devel/libg19draw/Makefile
 sed 's/^X//' >devel/libg19draw/Makefile << '6e1cdfa97bbe845ce7193e7227961557'
 X# New ports collection makefile for:	libg19draw
 X# Date created:				Apr 15 2011
 X# Whom:					Armin Pirkovitsch <armin at frozen-zone.org>
 X#
 X# $FreeBSD$
 X#
 X
 XPORTNAME=	libg19draw
 XPORTVERSION=	1.0.0
 XCATEGORIES=	devel
 XMASTER_SITES=	SF/g19linux/${PORTNAME}/${PORTNAME}-${PORTVERSION}
 X
 XMAINTAINER=	armin at frozen-zone.org
 XCOMMENT=	G19 draw library
 X
 XLIB_DEPENDS=	g19.1:${PORTSDIR}/devel/libg19 \
 X		freetype.9:${PORTSDIR}/print/freetype2
 X
 XCONFIGURE_ENV=	LDFLAGS="-L${LOCALBASE}/lib -pthread"
 X
 XUSE_LDCONFIG=	yes
 XGNU_CONFIGURE=	yes
 X
 XPLIST_FILES=	include/libg19draw.h \
 X		lib/libg19draw.a \
 X		lib/libg19draw.la \
 X		lib/libg19draw.so \
 X		lib/libg19draw.so.1
 X
 X.include <bsd.port.mk>
 6e1cdfa97bbe845ce7193e7227961557
 echo x - devel/libg19draw/distinfo
 sed 's/^X//' >devel/libg19draw/distinfo << '2d13fec53769adda70f63fa6f1dbae4d'
 XSHA256 (libg19draw-1.0.0.tar.gz) = 6ac1205f97f59d9fd7ac3cf8af96e6559fec797300884fb5385cc7e594a3ca7f
 XSIZE (libg19draw-1.0.0.tar.gz) = 327873
 2d13fec53769adda70f63fa6f1dbae4d
 echo c - devel/libg19draw/files
 mkdir -p devel/libg19draw/files > /dev/null 2>&1
 echo x - devel/libg19draw/files/patch-libg19draw.c
 sed 's/^X//' >devel/libg19draw/files/patch-libg19draw.c << 'dcabda67adf2ff59f7f3889f9fe9c873'
 X--- libg19draw.c.orig	2010-04-11 03:29:42.000000000 +0200
 X+++ libg19draw.c	2011-04-16 08:41:30.000000000 +0200
 X@@ -21,22 +21,211 @@
 X #include <stdlib.h>
 X #include <string.h>
 X 
 X-#include "config.h"
 X+#include <config.h>
 X #include "libg19draw.h"
 X 
 X+
 X #ifdef FT2_SUPPORT
 X+
 X+#include "libg19draw.h"
 X+
 X #include <ft2build.h>
 X #include FT_FREETYPE_H
 X #include FT_BITMAP_H
 X 
 X-static FT_Library ft_lib;
 X-static FT_Face ft_face;
 X-static int ft_width;
 X-static int ft_height;
 X-static int ft_space;
 X-static unsigned int ft_color;
 X+/**
 X+ * Creates a new G19Font
 X+ * 
 X+ * @param ttf_path path to the ttf file
 X+ * @param width width of text
 X+ * @param height height of text
 X+ * @param space space between characters in pixels
 X+ * @param color an unsigned int that hold the color; G19Color() or G19ColorA() can be used
 X+ * 
 X+ * @return pointer to a G19Font or NULL on error
 X+ **/
 X+G19Font * g19_font_new(char * ttf_path, int width, int height, int space, unsigned int color)
 X+{
 X+	G19Font * font = malloc(sizeof(G19Font));
 X+	
 X+	if(FT_Init_FreeType(&font -> lib))
 X+		return NULL;
 X+	
 X+	if(FT_New_Face(font -> lib, ttf_path, 0, &font -> face))
 X+	{
 X+		FT_Done_FreeType(font -> lib);
 X+		return NULL;
 X+	}
 X+	
 X+	if(FT_Set_Pixel_Sizes(font -> face, width, height))
 X+	{
 X+		FT_Done_Face(font -> face);
 X+		FT_Done_FreeType(font -> lib);
 X+		return NULL;
 X+	}
 X+	
 X+	font -> width = width;
 X+	font -> height = height;
 X+	font -> space = space;
 X+	font -> color = color;
 X+	
 X+	return font;
 X+}
 X+
 X+/**
 X+ * Sets the character size on the G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X+ * @param width width of text
 X+ * @param height height of text
 X+ **/
 X+void g19_font_set_size(G19Font * font, int width, int height)
 X+{
 X+	if(font == NULL)
 X+		return;
 X+	
 X+	FT_Set_Pixel_Sizes(font -> face, width, height);
 X+	
 X+	font -> width = width;
 X+	font -> height = height;
 X+}
 X+
 X+/**
 X+ * Sets the character spacing on the G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X+ * @param space between characters in pixels
 X+ **/
 X+void g19_font_set_space(G19Font * font, int space)
 X+{
 X+	if(font == NULL)
 X+		return;
 X+	
 X+	font -> space = space;
 X+}
 X+
 X+/**
 X+ * Sets the color on the G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X+ * @param color the color to set the text; G19Color() or G19ColorA() can be used
 X+ **/
 X+void g19_font_set_color(G19Font * font, unsigned int color)
 X+{
 X+	if(font == NULL)
 X+		return;
 X+	
 X+	font -> color = color;
 X+}
 X+
 X+/**
 X+ * Draws text on the G19Draw with G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X+ * @param draw a pointer G19Draw
 X+ * @param x x coordinate of the upper-left
 X+ * @param y y coordinate of the upper-left
 X+ * @param text pointer to an array of chars to be drawn
 X+ * 
 X+ * @return the number of characters written or < 0 on error
 X+ **/
 X+int g19_font_draw(G19Font * font, G19Draw * draw, int x, int y, char * text)
 X+{
 X+	if((font == NULL) || (draw == NULL))
 X+		return -1;
 X+	
 X+	if((font -> lib == NULL) || (font -> face == NULL))
 X+		return -1;
 X+	
 X+	int res, i;
 X+	FT_GlyphSlot slot;
 X+	FT_UInt gi;
 X+	
 X+	slot = font -> face -> glyph;
 X+	
 X+	for(i = 0; i < strlen(text); i++)
 X+	{
 X+		gi = FT_Get_Char_Index(font -> face, text[i]);
 X+		
 X+		if(gi == 0)
 X+			continue;
 X+		
 X+		res = FT_Load_Char(font -> face, (FT_ULong) text[i], FT_LOAD_DEFAULT);
 X+		if(res)
 X+			continue;
 X+		
 X+		res = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
 X+		if(res)
 X+			continue;
 X+		
 X+		if(slot -> bitmap.width < 1)
 X+		{
 X+			x += (font -> width / 2);
 X+			continue;
 X+		}
 X+		
 X+		x += font -> space;
 X+		
 X+		if((x + slot -> bitmap.width) >= draw -> width)
 X+			break;
 X+		
 X+		int xx, yy;
 X+		unsigned char tc;
 X+		unsigned int bcolor, fcolor;
 X+		int r, g, b;
 X+		
 X+		for(yy = 0; yy < slot -> bitmap.rows; yy++)
 X+		{
 X+			for(xx = 0; xx < slot -> bitmap.width; xx++)
 X+			{
 X+				tc = slot -> bitmap.buffer[(yy * slot -> bitmap.width) + xx];
 X+				
 X+				if(tc == 0)
 X+					continue;
 X+				
 X+				bcolor = g19_draw_get_pixel(draw, xx, yy);
 X+				
 X+				r = G19R(bcolor) + (((G19R(font -> color) - G19R(bcolor)) * tc) / 256);
 X+				g = G19G(bcolor) + (((G19G(font -> color) - G19G(bcolor)) * tc) / 256);
 X+				b = G19B(bcolor) + (((G19B(font -> color) - G19B(bcolor)) * tc) / 256);
 X+				
 X+				fcolor = G19Color(r, g, b);
 X+				
 X+				g19_draw_set_pixel(draw, slot -> bitmap_left + xx + x,
 X+								  (font -> height - slot -> bitmap_top) + yy + y, fcolor);
 X+			}
 X+		}
 X+		
 X+		x += slot -> bitmap.width;
 X+	}
 X+	
 X+	return i;
 X+}
 X+
 X+/**
 X+ * Frees a G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X+ **/
 X+void g19_font_free(G19Font * font)
 X+{
 X+	if(font == NULL)
 X+		return;
 X+	
 X+	if(font -> face != NULL)
 X+		FT_Done_Face(font -> face);
 X+	
 X+	if(font -> lib != NULL)
 X+		FT_Done_FreeType(font -> lib);
 X+	
 X+	free(font);
 X+}
 X+
 X #endif
 X 
 X+
 X+
 X+
 X /**
 X  * Creates a new G19Draw
 X  * 
 X@@ -49,13 +238,13 @@
 X {
 X 	G19Draw * draw;
 X 	
 X-	draw = (G19Draw *) malloc(sizeof(G19Draw));
 X+	draw = malloc(sizeof(G19Draw));
 X 	
 X 	draw -> width = width;
 X 	draw -> height = height;
 X 	draw -> size = width * height * 4;
 X 	
 X-	draw -> data = (unsigned char *) malloc(draw -> size);
 X+	draw -> data = malloc(draw -> size);
 X 	memset(draw -> data, 0x00, draw -> size);
 X 	
 X 	return draw;
 X@@ -143,9 +332,9 @@
 X 	
 X 	fseek(file, doff, SEEK_SET);
 X 	
 X-	for(x = 0; x < width; x++)
 X+	for(y = height - 1; y > 0; y--)
 X 	{
 X-		for(y = 0; y < height; y++)
 X+		for(x = 0; x < width; x++)
 X 		{
 X 			if(bits == 24)
 X 			{
 X@@ -158,7 +347,7 @@
 X 				color = G19ColorA(buffer[2], buffer[1], buffer[0], buffer[3]);
 X 			}
 X 			
 X-			g19_draw_set_pixel(draw, y + (width - height), ((width + (height - width)) - 1) - x, color);
 X+			g19_draw_set_pixel(draw, x, y, color);
 X 		}
 X 	}
 X 	
 X@@ -184,6 +373,98 @@
 X }
 X 
 X /**
 X+ * Save a G19Draw to an 24-bit bitmap
 X+ * 
 X+ * @param draw pointer to a G19Draw
 X+ * @param path path to save the image to
 X+ * 
 X+ * @return 0 on success; non-zero on error
 X+ **/
 X+int g19_draw_to_bmp(G19Draw * draw, char * path)
 X+{
 X+	FILE * fp;
 X+	unsigned char * bmp;
 X+	int data_size, bmp_size;
 X+	int d ,x, y;
 X+	unsigned int color;
 X+	
 X+	fp = fopen(path, "wb");
 X+	if(fp == NULL)
 X+		return -1;
 X+	
 X+	data_size = (draw -> width * draw -> height) * 4;
 X+	bmp_size = data_size + 54;
 X+	
 X+	bmp = malloc(bmp_size);
 X+	memset(bmp, 0, bmp_size);
 X+	
 X+	bmp[0x0]	= 0x42;
 X+	bmp[0x1]	= 0x4d;
 X+	bmp[0xa]	= 0x36;
 X+	bmp[0xe]	= 0x28;
 X+	bmp[0x1a]	= 0x1;
 X+	bmp[0x1c]	= 0x20;
 X+	
 X+	d = 2835;
 X+	
 X+	memcpy(bmp + 0x2, &bmp_size, 4);
 X+	memcpy(bmp + 0x12, &draw -> width, 4);
 X+	memcpy(bmp + 0x16, &draw -> height, 4);
 X+	memcpy(bmp + 0x22, &data_size, 4);
 X+	memcpy(bmp + 0x26, &d, 4);
 X+	memcpy(bmp + 0x2a, &d, 4);
 X+	
 X+	d = 0;
 X+	for(y = draw -> height - 1; y > 0; y--)
 X+	{
 X+		for(x = 0; x < draw -> width; x++)
 X+		{
 X+			color = g19_draw_get_pixel(draw, x, y);
 X+			color = G19ColorA(G19B(color), G19G(color),
 X+							  G19R(color), 0xff);
 X+			
 X+			memcpy(bmp + ((d * 4) + 0x36), &color, 4);
 X+			d++;
 X+		}
 X+	}
 X+	
 X+	fwrite(bmp, 1, bmp_size, fp);
 X+	free(bmp);
 X+	
 X+	fclose(fp);
 X+	
 X+	return 0;
 X+}
 X+
 X+/**
 X+ * Resizes a G19Draw
 X+ * 
 X+ * @param width width in pixels to resize to
 X+ * @param height height in pixels to resize to
 X+ * @param color the base color of the new image; G19Color() or G19ColorA() can be used
 X+ * @param free_old free the allocated memory of the old old G19Draw; 0 for no, 1 for yes
 X+ * 
 X+ * @return a pointer to the new G19Draw or NULL on error
 X+ **/
 X+G19Draw * g19_draw_resize(G19Draw * draw, int width, int height, unsigned int color, int free_old)
 X+{
 X+	if(draw == NULL)
 X+		return NULL;
 X+	
 X+	if((width < 1) || (height < 1))
 X+		return NULL;
 X+	
 X+	G19Draw * resize = g19_draw_new(width, height);
 X+	g19_draw_fill(resize, color);
 X+	g19_draw_insert(resize, draw, 0, 0);
 X+	
 X+	if(free_old)
 X+		g19_draw_free(draw);
 X+	
 X+	return resize;
 X+}
 X+
 X+/**
 X  * Insert a G19Draw onto another G19Draw
 X  * 
 X  * @param draw pointer to the destination G19Draw
 X@@ -242,7 +523,7 @@
 X 	int x, y;
 X 	int dd, id;
 X 	unsigned char d1[4], d2[4];
 X-	int r, g, b;
 X+	unsigned char r, g, b;
 X 	unsigned int color;
 X 	
 X 	ex = ((ix + idraw -> width) < draw -> width) ? idraw -> width : (draw -> width - ix);
 X@@ -378,7 +659,7 @@
 X 	
 X 	err = dx / 2;
 X 	y = y1;
 X-	ystep = (y1 < y2) ? 1 : 0;
 X+	ystep = (y1 < y2) ? 1 : -1;
 X 	
 X 	for(x = x1; x < x2; x++)
 X 	{
 X@@ -388,7 +669,7 @@
 X 			g19_draw_set_pixel(draw, x, y, color);
 X 		
 X 		err = err - dy;
 X-		if(!err)
 X+		if(err < 0)
 X 		{
 X 			y = y + ystep;
 X 			err = err + dx;
 X@@ -417,7 +698,7 @@
 X 		g19_draw_line(draw, left, top, right, top, color);
 X 		g19_draw_line(draw, left, bottom, right, bottom, color);
 X 		g19_draw_line(draw, left, top, left, bottom, color);
 X-		g19_draw_line(draw, right, top, right, bottom, color);
 X+		g19_draw_line(draw, right, top, right, bottom + 1, color);
 X 		
 X 		return;
 X 	}
 X@@ -494,159 +775,3 @@
 X 	}
 X 	
 X }
 X-
 X-/**
 X- * Draws a slot from FreeType on the G19Draw
 X- * 
 X- * @param draw a pointer G19Draw
 X- * @param fslot G19FontSlot that holds the FreeType slot data
 X- **/
 X-void g19_draw_ft_slot(G19Draw * draw, G19FontSlot * fslot, int x, int y)
 X-{
 X-	int xx, yy;
 X-	unsigned char tc;
 X-	unsigned int fcolor;
 X-	
 X-	if(draw == NULL)
 X-		return;
 X-	
 X-	G19FontBitmap * bitmap = fslot -> bitmap;
 X-	
 X-	G19Draw * tdraw = g19_draw_new(fslot -> width, fslot -> bitmap_top + fslot -> height);
 X-	g19_draw_fill(tdraw, G19ColorA(0, 0, 0, 0));
 X-	
 X-	if(tdraw == NULL)
 X-		return;
 X-	
 X-	for(yy = 0; yy < bitmap -> rows; yy++)
 X-	{
 X-		for(xx = 0; xx < bitmap -> width; xx++)
 X-		{
 X-			tc = bitmap -> buffer[(yy * bitmap -> width) + xx];
 X-			
 X-			if(tc == 0)
 X-				continue;
 X-			
 X-			fcolor = G19ColorA(G19R(fslot -> color), G19G(fslot -> color),
 X-							  G19B(fslot -> color), (256 + tc));
 X-			
 X-			g19_draw_set_pixel(tdraw, fslot -> bitmap_left + xx, (fslot -> height - fslot -> bitmap_top) + yy, fcolor);
 X-		}
 X-	}
 X-	
 X-	g19_draw_insert_ab(draw, tdraw, x, y, -1);
 X-	g19_draw_free(tdraw);
 X-}
 X-
 X-#ifdef FT2_SUPPORT
 X-
 X-/**
 X- * Sets the font for drawing
 X- * 
 X- * @param ttf_path path to the ttf file
 X- * @param width width of text
 X- * @param height height of text
 X- * @param space space between chars in pixels
 X- * @param color an unsigned int that hold the color; G19Color() or G19ColorA() can be used
 X- * 
 X- * @return non zero on failure
 X- **/
 X-int g19_draw_set_font(char * ttf_path, int width, int height, int space, unsigned int color)
 X-{
 X-	int res = FT_Init_FreeType(&ft_lib);
 X-	if(res)
 X-		return res;
 X-	
 X-	res = FT_New_Face(ft_lib, ttf_path, 0, &ft_face);
 X-	if(res)
 X-		return res;
 X-	
 X-	res = FT_Set_Pixel_Sizes(ft_face, width, height);
 X-	if(res)
 X-		return res;
 X-	
 X-	ft_width = width;
 X-	ft_height = height;
 X-	ft_space = space;
 X-	ft_color = color;
 X-	
 X-	if(space < 0)
 X-		space = 0;
 X-	
 X-	return 0;
 X-}
 X-
 X-/**
 X- * Draws text on the G19Draw
 X- * Make sure you have executed g19_draw_set_font
 X- * 
 X- * @param draw a pointer G19Draw
 X- * @param x x coordinate of the upper-left
 X- * @param y y coordinate of the upper-left
 X- * @param text pointer to an array of chars to be drawn
 X- * 
 X- * @return non zero on failure
 X- **/
 X-int g19_draw_text(G19Draw * draw, int x, int y, char * text)
 X-{
 X-	int res, i;
 X-	FT_GlyphSlot slot;
 X-	FT_UInt gi;
 X-	
 X-	if((ft_lib == NULL) || (ft_face == NULL))
 X-		return -1;
 X-	
 X-	slot = ft_face -> glyph;
 X-	
 X-	for(i = 0; i < strlen(text); i++)
 X-	{
 X-		gi = FT_Get_Char_Index(ft_face, text[i]);
 X-		
 X-		if(gi == 0)
 X-			continue;
 X-		
 X-		res = FT_Load_Char(ft_face, (FT_ULong) text[i], FT_LOAD_DEFAULT);
 X-		if(res)
 X-			continue;
 X-		
 X-		res = FT_Render_Glyph(ft_face -> glyph, FT_RENDER_MODE_NORMAL);
 X-		if(res)
 X-			continue;
 X-		
 X-		if(slot -> bitmap.width < 1)
 X-		{
 X-			x += ft_width;
 X-			continue;
 X-		}
 X-		
 X-		x += ft_space;
 X-		
 X-		G19FontSlot fslot;
 X-		fslot.width = ft_width;
 X-		fslot.height = ft_height;
 X-		fslot.bitmap_left = slot -> bitmap_left;
 X-		fslot.bitmap_top = slot -> bitmap_top;
 X-		fslot.color = ft_color;
 X-		fslot.bitmap = (G19FontBitmap *) &slot -> bitmap;
 X-		
 X-		g19_draw_ft_slot(draw, &fslot, x, y);
 X-		
 X-		x += slot -> bitmap.width;
 X-	}
 X-	
 X-	return 0;
 X-}
 X-
 X-/**
 X- * Closes the FreeType library and font handle from g19_draw_set_font()
 X- **/
 X-void g19_draw_close_font(void)
 X-{
 X-	if(ft_face != NULL)
 X-		FT_Done_Face(ft_face);
 X-	
 X-	if(ft_lib != NULL)
 X-		FT_Done_FreeType(ft_lib);
 X-}
 X-
 X-#endif
 dcabda67adf2ff59f7f3889f9fe9c873
 echo x - devel/libg19draw/files/patch-libg19draw.h
 sed 's/^X//' >devel/libg19draw/files/patch-libg19draw.h << 'babc2c3368215041888634e41488cd53'
 X--- libg19draw.h.orig	2010-04-11 04:51:51.000000000 +0200
 X+++ libg19draw.h	2011-04-16 08:26:10.000000000 +0200
 X@@ -19,12 +19,26 @@
 X #ifndef LIBG19DRAW_H
 X #define LIBG19DRAW_H
 X 
 X+#include <string.h>
 X+
 X+#ifdef FT2_SUPPORT
 X+
 X+#include <ft2build.h>
 X+#include FT_FREETYPE_H
 X+#include FT_BITMAP_H
 X+
 X+#endif
 X+
 X #ifdef __cplusplus
 X extern "C"
 X {
 X #endif
 X 
 X-#define LIBG19DRAW_VERSION "1.0.0"
 X+#define LIBG19DRAW_VERSION_MAJOR	1
 X+#define LIBG19DRAW_VERSION_MINOR	1
 X+#define LIBG19DRAW_VERSION_MICRO	0
 X+
 X+#define LIBG19DRAW_VERSION			"1.1.0"
 X 
 X #define G19_WIDTH		320
 X #define G19_HEIGHT		240
 X@@ -44,30 +58,25 @@
 X {
 X 	int width;
 X 	int height;
 X-	int size;
 X+	size_t size;
 X 	unsigned char * data;
 X }
 X G19Draw;
 X 
 X-typedef struct
 X-{
 X-	int rows;
 X-	int width;
 X-	int pitch;
 X-	unsigned char * buffer;
 X-}
 X-G19FontBitmap;
 X+#ifdef FT2_SUPPORT
 X 
 X typedef struct
 X {
 X+	FT_Library lib;
 X+	FT_Face face;
 X 	int width;
 X 	int height;
 X-	int bitmap_left;
 X-	int bitmap_top;
 X+	int space;
 X 	unsigned int color;
 X-	G19FontBitmap * bitmap;
 X }
 X-G19FontSlot;
 X+G19Font;
 X+
 X+#endif
 X 
 X /**
 X  * Creates a new G19Draw
 X@@ -99,6 +108,28 @@
 X void g19_draw_free(G19Draw * draw);
 X 
 X /**
 X+ * Save a G19Draw to an 24-bit bitmap
 X+ * 
 X+ * @param draw pointer to a G19Draw
 X+ * @param path path to save the image to
 X+ * 
 X+ * @return 0 on success; non-zero on error
 X+ **/
 X+int g19_draw_to_bmp(G19Draw * draw, char * path);
 X+
 X+/**
 X+ * Resizes a G19Draw
 X+ * 
 X+ * @param width width in pixels to resize to
 X+ * @param height height in pixels to resize to
 X+ * @param color the base color of the new image; G19Color() or G19ColorA() can be used
 X+ * @param free_old free the allocated memory of the old old G19Draw; 0 for no, 1 for yes
 X+ * 
 X+ * @return a pointer to the new G19Draw or NULL on error
 X+ **/
 X+G19Draw * g19_draw_resize(G19Draw * draw, int width, int height, unsigned int color, int free_old);
 X+
 X+/**
 X  * Insert a G19Draw onto another G19Draw
 X  * 
 X  * @param draw pointer to the destination G19Draw
 X@@ -185,18 +216,11 @@
 X  **/
 X void g19_draw_circle(G19Draw * draw, int cx, int cy, int cr, int fill, unsigned int color);
 X 
 X-/**
 X- * Draws a slot from FreeType on the G19Draw
 X- * 
 X- * @param draw a pointer G19Draw
 X- * @param fslot G19FontSlot that holds the FreeType slot data
 X- **/
 X-void g19_draw_ft_slot(G19Draw * draw, G19FontSlot * fslot, int x, int y);
 X 
 X #ifdef FT2_SUPPORT
 X 
 X /**
 X- * Sets the font for drawing
 X+ * Creates a new G19Font
 X  * 
 X  * @param ttf_path path to the ttf file
 X  * @param width width of text
 X@@ -204,27 +228,55 @@
 X  * @param space space between chars in pixels
 X  * @param color an unsigned int that hold the color; G19Color() or G19ColorA() can be used
 X  * 
 X- * @return non zero on failure
 X+ * @return pointer to a G19Font or NULL on error
 X+ **/
 X+G19Font * g19_font_new(char * ttf_path, int width, int height, int space, unsigned int color);
 X+
 X+/**
 X+ * Sets the character size on the G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X+ * @param width width of text
 X+ * @param height height of text
 X+ **/
 X+void g19_font_set_size(G19Font * font, int width, int height);
 X+
 X+/**
 X+ * Sets the character spacing on the G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X+ * @param space between characters in pixels
 X  **/
 X-int g19_draw_set_font(char * ttf_path, int width, int height, int space, unsigned int color);
 X+void g19_font_set_space(G19Font * font, int space);
 X 
 X /**
 X- * Draws text on the G19Draw
 X- * Make sure you have executed g19_draw_set_font
 X+ * Sets the color on the G19Font
 X  * 
 X+ * @param font a pointer G19Font
 X+ * @param color the color to set the text; G19Color() or G19ColorA() can be used
 X+ **/
 X+void g19_font_set_color(G19Font * font, unsigned int color);
 X+
 X+/**
 X+ * Draws text on the G19Draw with G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X  * @param draw a pointer G19Draw
 X  * @param x x coordinate of the upper-left
 X  * @param y y coordinate of the upper-left
 X  * @param text pointer to an array of chars to be drawn
 X  * 
 X- * @return non zero on failure
 X+ * @return the number of characters written or < 0 on error
 X  **/
 X-int g19_draw_text(G19Draw * draw, int x, int y, char * text);
 X+int g19_font_draw(G19Font * font, G19Draw * draw, int x, int y, char * text);
 X+
 X 
 X /**
 X- * Closes the FreeType library and font handle from g19_draw_set_font()
 X+ * Frees a G19Font
 X+ * 
 X+ * @param font a pointer G19Font
 X  **/
 X-void g19_draw_close_font(void);
 X+void g19_font_free(G19Font * font);
 X 
 X #endif
 X 
 babc2c3368215041888634e41488cd53
 echo x - devel/libg19draw/files/patch-configure
 sed 's/^X//' >devel/libg19draw/files/patch-configure << '12a34483e3e6887a1517db3450a0ac8b'
 X--- configure.orig	2010-04-11 05:19:11.000000000 +0200
 X+++ configure	2011-04-16 08:44:40.000000000 +0200
 X@@ -20199,9 +20199,9 @@
 X fi
 X 
 X 
 X-{ $as_echo "$as_me:$LINENO: checking for g19_update_lcd_bmp in -lg19" >&5
 X-$as_echo_n "checking for g19_update_lcd_bmp in -lg19... " >&6; }
 X-if test "${ac_cv_lib_g19_g19_update_lcd_bmp+set}" = set; then
 X+{ $as_echo "$as_me:$LINENO: checking for g19_update_lcd in -lg19" >&5
 X+$as_echo_n "checking for g19_update_lcd in -lg19... " >&6; }
 X+if test "${ac_cv_lib_g19_g19_update_lcd+set}" = set; then
 X   $as_echo_n "(cached) " >&6
 X else
 X   ac_check_lib_save_LIBS=$LIBS
 X@@ -20219,11 +20219,11 @@
 X #ifdef __cplusplus
 X extern "C"
 X #endif
 X-char g19_update_lcd_bmp ();
 X+char g19_update_lcd ();
 X int
 X main ()
 X {
 X-return g19_update_lcd_bmp ();
 X+return g19_update_lcd ();
 X   ;
 X   return 0;
 X }
 X@@ -20249,12 +20249,12 @@
 X 	 test "$cross_compiling" = yes ||
 X 	 $as_test_x conftest$ac_exeext
 X        }; then
 X-  ac_cv_lib_g19_g19_update_lcd_bmp=yes
 X+  ac_cv_lib_g19_g19_update_lcd=yes
 X else
 X   $as_echo "$as_me: failed program was:" >&5
 X sed 's/^/| /' conftest.$ac_ext >&5
 X 
 X-	ac_cv_lib_g19_g19_update_lcd_bmp=no
 X+	ac_cv_lib_g19_g19_update_lcd=no
 X fi
 X 
 X rm -rf conftest.dSYM
 X@@ -20262,9 +20262,9 @@
 X       conftest$ac_exeext conftest.$ac_ext
 X LIBS=$ac_check_lib_save_LIBS
 X fi
 X-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_g19_g19_update_lcd_bmp" >&5
 X-$as_echo "$ac_cv_lib_g19_g19_update_lcd_bmp" >&6; }
 X-if test "x$ac_cv_lib_g19_g19_update_lcd_bmp" = x""yes; then
 X+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_g19_g19_update_lcd" >&5
 X+$as_echo "$ac_cv_lib_g19_g19_update_lcd" >&6; }
 X+if test "x$ac_cv_lib_g19_g19_update_lcd" = x""yes; then
 X   cat >>confdefs.h <<_ACEOF
 X #define HAVE_LIBG19 1
 X _ACEOF
 12a34483e3e6887a1517db3450a0ac8b
 echo x - devel/libg19draw/pkg-descr
 sed 's/^X//' >devel/libg19draw/pkg-descr << '05289a39856da0722171831965e12233'
 XA library that can be used for drawing images, circles, lines and test on
 Xthe LCD
 X
 XWWW: http://g19linux.sourceforge.net/
 05289a39856da0722171831965e12233
 exit
 
 
 --------------000904040502090806090507--



More information about the freebsd-ports-bugs mailing list