CVS update: php31/ext/gd

From: Date: Mon, 14 Sep 1998 16:56:27 +0000
Subject: CVS update: php31/ext/gd
Groups: php.dev 
Request: Send a blank email to php-dev+get-1060@lists.php.net to get a copy of this message
Date: Monday September 14, 1998 @ 12:56 Author: shane Update of /repository/php31/ext/gd In directory asf:/u2/tmp/cvs-serv18848/ext/gd Modified Files: gd.c gd.dsp gdcache.c gdttf.c php3_gd.h Log Message: Hmm, several things I've been working on that I don't remember specifics of. mysql compiles with the latest windows stuff I've been working on with monty. odbc fixes from 3.0 tree adding gdlib to project (now that I have a reentrant version, still needs testing) Index: php31/ext/gd/gd.c diff -c php31/ext/gd/gd.c:2.3 php31/ext/gd/gd.c:2.4 *** php31/ext/gd/gd.c:2.3 Sat Jul 11 20:57:58 1998 --- php31/ext/gd/gd.c Mon Sep 14 12:56:26 1998 *************** *** 29,35 **** +----------------------------------------------------------------------+ */ ! /* $Id: gd.c,v 2.3 1998/07/12 00:57:58 ssb Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ --- 29,35 ---- +----------------------------------------------------------------------+ */ ! /* $Id: gd.c,v 2.4 1998/09/14 16:56:26 shane Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ *************** *** 64,77 **** #include <gdfontl.h> /* 4 Large font */ #include <gdfontg.h> /* 5 Giant font */ #if HAVE_LIBTTF ! #include "gdttf.h" #endif #ifndef M_PI #define M_PI 3.14159265358979323846 #endif static void php3_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int); #ifdef THREAD_SAFE DWORD GDlibTls; --- 64,79 ---- #include <gdfontl.h> /* 4 Large font */ #include <gdfontg.h> /* 5 Giant font */ #if HAVE_LIBTTF ! #include <functions/gdttf.h> #endif #ifndef M_PI #define M_PI 3.14159265358979323846 #endif + #if HAVE_LIBTTF static void php3_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int); + #endif #ifdef THREAD_SAFE DWORD GDlibTls; *************** *** 142,148 **** }; #if COMPILE_DL ! #include "dl/phpdl.h" DLEXPORT php3_module_entry *get_module(void) { return &gd_module_entry; } #if (WIN32|WINNT) && defined(THREAD_SAFE) --- 144,154 ---- }; #if COMPILE_DL ! # if PHP_31 ! # include "ext/phpdl.h" ! # else ! # include "dl/phpdl.h" ! # endif DLEXPORT php3_module_entry *get_module(void) { return &gd_module_entry; } #if (WIN32|WINNT) && defined(THREAD_SAFE) *************** *** 203,213 **** --- 209,223 ---- } void php3_info_gd(void) { + /* need to use a PHPAPI function here because it is external module in windows */ #if HAVE_LIBGD13 php3_printf("Version 1.3"); #else php3_printf("Version 1.2"); #endif + #if HAVE_LIBTTF + php3_printf(" with FreeType support"); + #endif } int php3_mend_gd(void){ *************** *** 291,297 **** void php3_imageloadfont(INTERNAL_FUNCTION_PARAMETERS) { pval *file; int hdr_size = sizeof(gdFont) - sizeof(char *); ! int ind, body_size, n, b; gdFontPtr font; FILE *fp; int issock=0, socketd=0; --- 301,307 ---- void php3_imageloadfont(INTERNAL_FUNCTION_PARAMETERS) { pval *file; int hdr_size = sizeof(gdFont) - sizeof(char *); ! int ind, body_size, n=0, b; gdFontPtr font; FILE *fp; int issock=0, socketd=0; *************** *** 695,701 **** if (argc == 2) { convert_to_string(file); fn = file->value.str.val; ! if (!fn || fn == empty_string) { php3_error(E_WARNING, "ImageGif: Invalid filename"); RETURN_FALSE; } --- 705,711 ---- if (argc == 2) { convert_to_string(file); fn = file->value.str.val; ! if (!fn || fn == empty_string || _php3_check_open_basedir(fn)) { php3_error(E_WARNING, "ImageGif: Invalid filename"); RETURN_FALSE; } *************** *** 947,954 **** convert_to_long(COL); col = COL->value.lval; ! e = E->value.lval; ! st = ST->value.lval; h = H->value.lval; w = W->value.lval; cy = CY->value.lval; --- 957,964 ---- convert_to_long(COL); col = COL->value.lval; ! e = E->value.lval % 360; ! st = ST->value.lval % 360; h = H->value.lval; w = W->value.lval; cy = CY->value.lval; *************** *** 1515,1521 **** unsigned char *string = NULL, *fontname = NULL; int ind_type; char *error; - unsigned int *str; GD_TLS_VARS; --- 1525,1530 ---- *************** *** 1534,1541 **** convert_to_string(FONTNAME); convert_to_string(C); if (mode == TTFTEXT_BBOX) { ! IM->type = IS_LONG; ! IM->value.lval = -1; col = x = y = -1; } else { convert_to_long(X); --- 1543,1549 ---- convert_to_string(FONTNAME); convert_to_string(C); if (mode == TTFTEXT_BBOX) { ! im = NULL; col = x = y = -1; } else { convert_to_long(X); *************** *** 1545,1550 **** --- 1553,1563 ---- col = COL->value.lval; y = Y->value.lval; x = X->value.lval; + im = php3_list_find(IM->value.lval, &ind_type); + if (!im || ind_type != GD_GLOBAL(le_gd)) { + php3_error(E_WARNING, "Unable to find image pointer"); + RETURN_FALSE; + } } ptsize = PTSIZE->value.dval; *************** *** 1553,1568 **** string = (unsigned char *) C->value.str.val; l = strlen(string); fontname = (unsigned char *) FONTNAME->value.str.val; - - if (mode == TTFTEXT_BBOX) { - im = NULL; - } else { - im = php3_list_find(IM->value.lval, &ind_type); - if (!im || ind_type != GD_GLOBAL(le_gd)) { - php3_error(E_WARNING, "Unable to find image pointer"); - RETURN_FALSE; - } - } error = gdttf(im, brect, col, fontname, ptsize, angle, x, y, string); --- 1566,1571 ---- Index: php31/ext/gd/gd.dsp diff -c php31/ext/gd/gd.dsp:2.0 php31/ext/gd/gd.dsp:2.1 *** php31/ext/gd/gd.dsp:2.0 Fri Jul 3 09:12:54 1998 --- php31/ext/gd/gd.dsp Mon Sep 14 12:56:26 1998 *************** *** 68,74 **** # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "\src\include" /I "\src\phpcvs\php3\\" /D "DEBUG" /D "_DEBUG" /D "HAVE_GDTTF" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" --- 68,74 ---- # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "\src\include" /I "./" /I "../../" /I "../../main" /D PHP_31=1 /D HAVE_GD=1 /D "THREAD_SAFE" /D "DEBUG" /D "_DEBUG" /D "HAVE_GDTTF" /D "COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" *************** *** 78,84 **** # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 ftlib.lib php.lib libgdttf.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept /libpath:"\src\lib" /libpath:"\src\phpcvs\php3\cgi_debug" !ENDIF --- 78,84 ---- # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 freetype.lib phpsapi_core.lib libgd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"c:\php31/php3_gd.dll" /pdbtype:sept /libpath:"\src\lib" /libpath:"c:\php31" !ENDIF *************** *** 88,102 **** # Name "gd - Win32 Debug" # Begin Source File ! SOURCE=.\functions\gd.c # End Source File # Begin Source File ! SOURCE=.\functions\gdttf.c # End Source File # Begin Source File ! SOURCE=.\functions\gdttf.h # End Source File # End Target # End Project --- 88,114 ---- # Name "gd - Win32 Debug" # Begin Source File ! SOURCE=.\gd.c # End Source File # Begin Source File ! SOURCE=.\gdcache.c # End Source File # Begin Source File ! SOURCE=.\gdcache.h ! # End Source File ! # Begin Source File ! ! SOURCE=.\gdttf.c ! # End Source File ! # Begin Source File ! ! SOURCE=.\gdttf.h ! # End Source File ! # Begin Source File ! ! SOURCE=.\php3_gd.h # End Source File # End Target # End Project Index: php31/ext/gd/gdcache.c diff -c php31/ext/gd/gdcache.c:2.0 php31/ext/gd/gdcache.c:2.1 *** php31/ext/gd/gdcache.c:2.0 Fri Jul 3 09:12:54 1998 --- php31/ext/gd/gdcache.c Mon Sep 14 12:56:27 1998 *************** *** 36,43 **** * sizes of a few tens of elements. */ #include "config.h" ! #if HAVE_LIBTTF #include "gdcache.h" --- 36,47 ---- * sizes of a few tens of elements. */ + /* This just seems unessacary */ + #if (WIN32|WINNT) + #define HAVE_LIBTTF 1 + #else #include "config.h" ! #endif #if HAVE_LIBTTF #include "gdcache.h" Index: php31/ext/gd/gdttf.c diff -c php31/ext/gd/gdttf.c:2.4 php31/ext/gd/gdttf.c:2.5 *** php31/ext/gd/gdttf.c:2.4 Fri Aug 7 05:20:45 1998 --- php31/ext/gd/gdttf.c Mon Sep 14 12:56:27 1998 *************** *** 3,23 **** /* John Ellson ellson@lucent.com */ #if WIN32|WINNT ! #include "config.w32.h" #else ! #include "config.h" #endif #if HAVE_LIBTTF #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> ! #include "gd.h" #include "gdttf.h" #include "gdcache.h" ! #include "freetype.h" - /* number of fonts cached before least recently used is replaced */ #define FONTCACHESIZE 6 --- 3,26 ---- /* John Ellson ellson@lucent.com */ #if WIN32|WINNT ! # if PHP_31 ! # include "os/nt/config.w32.h" ! # else ! # include "config.w32.h" ! # endif #else ! # include "config.h" #endif #if HAVE_LIBTTF #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> ! #include <gd.h> #include "gdttf.h" #include "gdcache.h" ! #include <freetype.h> /* number of fonts cached before least recently used is replaced */ #define FONTCACHESIZE 6 *************** *** 35,48 **** /* ptsize below which anti-aliasing is ineffective */ #define MINANTIALIASPTSIZE 0 ! /* display resolution - (Not really. This has to be 72 or hinting is wrong */ #define RESOLUTION 72 /* Number of colors used for anti-aliasing */ #define NUMCOLORS 4 /* Line separation as a factor of font height. ! No space between if LINESPACE = 1.00 */ #define LINESPACE 1.05 #ifndef TRUE --- 38,52 ---- /* ptsize below which anti-aliasing is ineffective */ #define MINANTIALIASPTSIZE 0 ! /* display resolution - (Not really. This has to be 72 or hinting is wrong) */ #define RESOLUTION 72 /* Number of colors used for anti-aliasing */ #define NUMCOLORS 4 /* Line separation as a factor of font height. ! No space between if LINESPACE = 1.00 ! Line separation will be rounded up to next pixel row*/ #define LINESPACE 1.05 #ifndef TRUE *************** *** 131,136 **** --- 135,198 ---- static void *bitmapFetch ( char **error, void *key ); static void bitmapRelease( void *element ); + /* local prototype */ + char *gdttfchar(gdImage *im, int fg, font_t *font, int x, int y, TT_F26Dot6 x1, TT_F26Dot6 y1, TT_F26Dot6 *advance, TT_BBox **bbox, char **next); + + /* This prototype is missing from gd.h */ + /* FIXME Since when does GD have this function??? My copy of 1.3 doesnt + int gdImageColorResolve(gdImagePtr im, int r, int g, int b); + */ + + /********************************************************************/ + /* gdImageColorResolve is a replacement for the old fragment: */ + /* */ + /* if ((color=gdImageColorExact(im,R,G,B)) < 0) */ + /* if ((color=gdImageColorAllocate(im,R,G,B)) < 0) */ + /* color=gdImageColorClosest(im,R,G,B); */ + /* */ + /* in a single function */ + + static int + gdImageColorResolve(gdImagePtr im, int r, int g, int b) + { + int c; + int ct = -1; + int op = -1; + long rd, gd, bd, dist; + long mindist = 3*255*255; /* init to max poss dist */ + + for (c = 0; c < im->colorsTotal; c++) { + if (im->open[c]) { + op = c; /* Save open slot */ + continue; /* Color not in use */ + } + rd = (long)(im->red [c] - r); + gd = (long)(im->green[c] - g); + bd = (long)(im->blue [c] - b); + dist = rd * rd + gd * gd + bd * bd; + if (dist < mindist) { + if (dist == 0) { + return c; /* Return exact match color */ + } + mindist = dist; + ct = c; + } + } + /* no exact match. We now know closest, but first try to allocate exact */ + if (op == -1) { + op = im->colorsTotal; + if (op == gdMaxColors) { /* No room for more colors */ + return ct; /* Return closest available color */ + } + im->colorsTotal++; + } + im->red [op] = r; + im->green[op] = g; + im->blue [op] = b; + im->open [op] = 0; + return op; /* Return newly allocated color */ + } + /******************************************************************** * gdTcl_UtfToUniChar is borrowed from ... */ *************** *** 339,354 **** return NULL; } - #if 0 - /* Set flag if font is rotated */ - if (a->angle == 0) { - TT_Set_Instance_Transform_Flags(a->instance, FALSE, FALSE); - } - else { - TT_Set_Instance_Transform_Flags(a->instance, TRUE, FALSE); - } - #endif - TT_Get_Instance_Metrics(a->instance, &a->imetrics); /* First, look for a Unicode charmap */ --- 401,406 ---- *************** *** 629,639 **** *next += len; glyphkey.character = ch; - #if 0 - glyphkey.hinting = (fg<0)?0:1; - #else glyphkey.hinting = 1; - #endif glyphkey.font = font; glyph = (glyph_t *)gdCacheGet(font->glyphCache, &glyphkey); if (! glyph) --- 681,687 ---- *************** *** 647,660 **** return (char *)NULL; /* render (via cache) a bitmap for the current fractional offset */ ! bitmapkey.xoffset = ((x1+32) & 63) - 32 - ((glyph->xmin + 32) & -64); ! bitmapkey.yoffset = ((y1+32) & 63) - 32 - ((glyph->ymin + 32) & -64); bitmapkey.glyph = glyph; gdCacheGet(glyph->bitmapCache, &bitmapkey); /* copy to gif, mapping colors */ ! x2 = x + (glyph->xmin + ((x1+32) & -64)) / 64; ! y2 = y - (glyph->ymin + ((y1+32) & -64)) / 64; tweencolorkey.fgcolor = fg; tweencolorkey.im = im; for (row = 0; row < glyph->Bit.rows; row++) { --- 695,708 ---- return (char *)NULL; /* render (via cache) a bitmap for the current fractional offset */ ! bitmapkey.xoffset = ((x1+32) & 63) - 32 - ((glyph->xmin+32) & -64); ! bitmapkey.yoffset = ((y1+32) & 63) - 32 - ((glyph->ymin+32) & -64); bitmapkey.glyph = glyph; gdCacheGet(glyph->bitmapCache, &bitmapkey); /* copy to gif, mapping colors */ ! x2 = x + (((glyph->xmin+32) & -64) + ((x1+32) & -64)) / 64; ! y2 = y - (((glyph->ymin+32) & -64) + ((y1+32) & -64)) / 64; tweencolorkey.fgcolor = fg; tweencolorkey.im = im; for (row = 0; row < glyph->Bit.rows; row++) { *************** *** 747,753 **** } /* newlines */ if (ch == '\n') { ! advance_y -= (TT_F26Dot6)((font->imetrics.y_ppem * LINESPACE) * 64); next++; continue; } --- 795,802 ---- } /* newlines */ if (ch == '\n') { ! advance_y -= (TT_F26Dot6)(font->imetrics.y_ppem * LINESPACE * 64); ! advance_y = (advance_y-32) & -64; /* round to next pixel row */ next++; continue; } Index: php31/ext/gd/php3_gd.h diff -c php31/ext/gd/php3_gd.h:2.2 php31/ext/gd/php3_gd.h:2.3 *** php31/ext/gd/php3_gd.h:2.2 Sat Jul 11 20:57:59 1998 --- php31/ext/gd/php3_gd.h Mon Sep 14 12:56:27 1998 *************** *** 29,35 **** */ ! /* $Id: php3_gd.h,v 2.2 1998/07/12 00:57:59 ssb Exp $ */ #ifndef _PHP3_GD_H #define _PHP3_GD_H --- 29,35 ---- */ ! /* $Id: php3_gd.h,v 2.3 1998/09/14 16:56:27 shane Exp $ */ #ifndef _PHP3_GD_H #define _PHP3_GD_H *************** *** 88,95 **** extern void _php3_gdimagecharup(gdImagePtr, gdFontPtr, int, int, int, int); extern void php3_imagedashedline(INTERNAL_FUNCTION_PARAMETERS); #ifdef HAVE_LIBTTF - extern void php3_imagettftext(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagettfbbox(INTERNAL_FUNCTION_PARAMETERS); #endif #else --- 88,95 ---- extern void _php3_gdimagecharup(gdImagePtr, gdFontPtr, int, int, int, int); extern void php3_imagedashedline(INTERNAL_FUNCTION_PARAMETERS); #ifdef HAVE_LIBTTF extern void php3_imagettfbbox(INTERNAL_FUNCTION_PARAMETERS); + extern void php3_imagettftext(INTERNAL_FUNCTION_PARAMETERS); #endif #else -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1060) next »