LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Takeshi Abe Date: Tue Jul 1 05:40:27 2008 Subject: cvs: gd /gd-pango gd_pango.c gd_pango.h /gd-pango/tests/pango units.c
tabe Tue Jul 1 11:40:27 2008 UTC
Modified files:
/gd/gd-pango gd_pango.c gd_pango.h
/gd/gd-pango/tests/pango units.c
Log:
introduced gdBBox.
http://cvs.php.net/viewvc.cgi/gd/gd-pango/gd_pango.c?r1=1.8&r2=1.9&diff_format=u
Index: gd/gd-pango/gd_pango.c
diff -u gd/gd-pango/gd_pango.c:1.8 gd/gd-pango/gd_pango.c:1.9
--- gd/gd-pango/gd_pango.c:1.8 Mon Jun 30 11:41:04 2008
+++ gd/gd-pango/gd_pango.c Tue Jul 1 11:40:27 2008
@@ -15,7 +15,7 @@
| Authors: Pierre-A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: gd_pango.c,v 1.8 2008/06/30 11:41:04 tabe Exp $ */
+/* $Id: gd_pango.c,v 1.9 2008/07/01 11:40:27 tabe Exp $ */
/**
* @file
* @brief Pango support for GD
@@ -24,7 +24,7 @@
*
* @author Pierre-Alain Joye
* @date 2006/12/19
- * $Id: gd_pango.c,v 1.8 2008/06/30 11:41:04 tabe Exp $
+ * $Id: gd_pango.c,v 1.9 2008/07/01 11:40:27 tabe Exp $
*/
/**
* \mainpage
@@ -875,7 +875,7 @@
* Pango enabled replacement for gdImageStringFT.
*
* @param *im gdImagePtr
- * @param brect int array of layout bounds
+ * @param *bbox gdBBox layout the resulting bounds
* @param fg foreground color
* @param *fontlist path to font file
* @param ptsize font size
@@ -885,7 +885,7 @@
* @param *string the text to draw
* @return A null char* on success, or an error string on failure
*/
-char *gdImageStringPangoFT(gdImagePtr im, int *brect, int fg, char *fontlist,
+char *gdImageStringPangoFT(gdImagePtr im, gdBBox *bbox, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string)
{
int r;
@@ -923,16 +923,16 @@
context->matrix = &affined_matrix;
}
- if (brect) {
+ if (bbox) {
int w = gdPangoGetLayoutWidth(context);
int h = gdPangoGetLayoutHeight(context);
if (angle == 0.) {
- brect[0] = x;
- brect[1] = y + h;
- brect[2] = x + w;
- brect[3] = y + h;
- brect[4] = x + w;
- brect[5] = y;
+ bbox->bottom_left.x = x;
+ bbox->bottom_left.y = y + h;
+ bbox->bottom_right.x = x + w;
+ bbox->bottom_right.y = y + h;
+ bbox->top_right.x = x + w;
+ bbox->top_right.y = y;
} else { /* rotated */
double sin_a = sin(angle);
double cos_a = cos(angle);
@@ -940,15 +940,15 @@
int h_cos_a = (int)ceil(h * cos_a);
int w_sin_a = (int)ceil(w * sin_a);
int w_cos_a = (int)ceil(w * cos_a);
- brect[0] = x + h_sin_a;
- brect[1] = y + h_cos_a;
- brect[2] = x + h_sin_a + w_cos_a;
- brect[3] = y + h_cos_a - w_sin_a;
- brect[4] = x + w_cos_a;
- brect[5] = y - w_sin_a;
+ bbox->bottom_left.x = x + h_sin_a;
+ bbox->bottom_left.y = y + h_cos_a;
+ bbox->bottom_right.x = x + h_sin_a + w_cos_a;
+ bbox->bottom_right.y = y + h_cos_a - w_sin_a;
+ bbox->top_right.x = x + w_cos_a;
+ bbox->top_right.y = y - w_sin_a;
}
- brect[6] = x;
- brect[7] = y;
+ bbox->top_left.x = x;
+ bbox->top_left.y = y;
}
if (im) gdPangoRenderTo(context, im, x, y);
http://cvs.php.net/viewvc.cgi/gd/gd-pango/gd_pango.h?r1=1.8&r2=1.9&diff_format=u
Index: gd/gd-pango/gd_pango.h
diff -u gd/gd-pango/gd_pango.h:1.8 gd/gd-pango/gd_pango.h:1.9
--- gd/gd-pango/gd_pango.h:1.8 Tue Jun 24 01:43:19 2008
+++ gd/gd-pango/gd_pango.h Tue Jul 1 11:40:27 2008
@@ -15,14 +15,14 @@
| Authors: Pierre-A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: gd_pango.h,v 1.8 2008/06/24 01:43:19 tabe Exp $ */
+/* $Id: gd_pango.h,v 1.9 2008/07/01 11:40:27 tabe Exp $ */
/**
* @file
* @brief Header file of gd-pango
*
* @author Pierre-Alain Joye
* @date 2006/12/19
- * $Id: gd_pango.h,v 1.8 2008/06/24 01:43:19 tabe Exp $
+ * $Id: gd_pango.h,v 1.9 2008/07/01 11:40:27 tabe Exp $
*/
#ifndef GD_PANGO_H
@@ -55,6 +55,16 @@
};
/**
+ * Defines a bounding box. Note that the box includes all of the corners.
+ */
+typedef struct { /* bounding box */
+ gdPoint bottom_left;
+ gdPoint bottom_right;
+ gdPoint top_right;
+ gdPoint top_left;
+} gdBBox;
+
+/**
* Defines a colors set. The foreground and background can be
* defined using a integer value returned by gdTrueColor(r,g,b).
* For example, you can use when you create a gdPangoContext.
@@ -140,7 +150,7 @@
extern char *gdImageStringPangoFT(
gdImagePtr im,
- int *brect,
+ gdBBox *bbox,
int fg,
char *fontlist,
double ptsize,
http://cvs.php.net/viewvc.cgi/gd/gd-pango/tests/pango/units.c?r1=1.3&r2=1.4&diff_format=u
Index: gd/gd-pango/tests/pango/units.c
diff -u gd/gd-pango/tests/pango/units.c:1.3 gd/gd-pango/tests/pango/units.c:1.4
--- gd/gd-pango/tests/pango/units.c:1.3 Mon Jun 30 11:44:32 2008
+++ gd/gd-pango/tests/pango/units.c Tue Jul 1 11:40:27 2008
@@ -212,27 +212,38 @@
gdPangoFreeContext(context);
}
+static int gdBBoxEqual(gdBBox *bbox1, gdBBox *bbox2)
+{
+ return (bbox1->bottom_left.x == bbox2->bottom_left.x &&
+ bbox1->bottom_left.y == bbox2->bottom_left.y &&
+ bbox1->bottom_right.x == bbox2->bottom_right.x &&
+ bbox1->bottom_right.y == bbox2->bottom_right.y &&
+ bbox1->top_right.x == bbox2->top_right.x &&
+ bbox1->top_right.y == bbox2->top_right.y &&
+ bbox1->top_left.x == bbox2->top_left.x &&
+ bbox1->top_left.y == bbox2->top_left.y);
+}
+
TEST(gdImageStringPangoFT)
{
gdPangoContext *context;
context = gdPangoCreateContext();
{
- int brect1[8], brect2[8];
+ gdBBox bbox1, bbox2;
int fg = gdTrueColorAlpha(0xFF, 0xFF, 0xFF, gdAlphaOpaque);
int k;
for (k=0; ttf_paths[k]; k++) {
char *r1, *r2;
- int i;
- r1 = gdImageStringPangoFT(NULL, brect1, fg, ttf_paths[k], 12., 0., 0, 0, "abc");
- r2 = gdImageStringPangoFT(NULL, brect2, fg, ttf_paths[k], 12., 0., 0, 0, "<span foreground='green'>a</span>bc");
+ r1 = gdImageStringPangoFT(NULL, &bbox1, fg, ttf_paths[k], 12., 0., 0, 0, "abc");
+ r2 = gdImageStringPangoFT(NULL, &bbox2, fg, ttf_paths[k], 12., 0., 0, 0, "<span foreground='green'>a</span>bc");
gdTestAssert(r1 == r2);
if (r1) continue;
- for (i=0; i<8; i++) gdTestAssert(brect1[i] == brect2[i]);
- r1 = gdImageStringPangoFT(NULL, brect1, fg, ttf_paths[k], 40., -G_PI/6, 0, 0, "abc");
- r2 = gdImageStringPangoFT(NULL, brect2, fg, ttf_paths[k], 40., -G_PI/6, 0, 0, "<span foreground='green'>a</span>bc");
+ gdTestAssert(gdBBoxEqual(&bbox1, &bbox2));
+ r1 = gdImageStringPangoFT(NULL, &bbox1, fg, ttf_paths[k], 40., -G_PI/6, 0, 0, "abc");
+ r2 = gdImageStringPangoFT(NULL, &bbox2, fg, ttf_paths[k], 40., -G_PI/6, 0, 0, "<span foreground='green'>a</span>bc");
gdTestAssert(r1 == r2);
if (r1) continue;
- for (i=0; i<8; i++) gdTestAssert(brect1[i] == brect2[i]);
+ gdTestAssert(gdBBoxEqual(&bbox1, &bbox2));
}
}
/* TODO */
| Navigate in group php.gd.cvs at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |