cvs: /php3 ChangeLog configure.in /php3/functions gd.c php3_gd.h

From: Date: Sun, 30 Jan 2000 20:48:37 +0000
Subject: cvs: /php3 ChangeLog configure.in /php3/functions gd.c php3_gd.h
Groups: php.dev 
Request: Send a blank email to php-dev+get-15060@lists.php.net to get a copy of this message
markonen Sun Jan 30 21:48:37 2000 EDT Modified files: /php3 ChangeLog configure.in /php3/functions gd.c php3_gd.h Log: Added ImageWbmp() for outputting WAP's Wireless Bitmaps Index: php3/ChangeLog diff -u php3/ChangeLog:1.816 php3/ChangeLog:1.817 --- php3/ChangeLog:1.816 Sat Jan 29 20:33:04 2000 +++ php3/ChangeLog Sun Jan 30 21:48:36 2000 @@ -2,6 +2,7 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ???, Version 3.0.15 +- Added ImageWbmp() for outputting WAP's Wireless Bitmaps (markonen) - Support for LZW-compressed GIFs with gd 1.5, gd/freetype cleanups (markonen) - Added IMAP modified UTF-7 encode/decode routines (Andrew Skalski) - Add .ini option to set the default charset for the default text/html mime Index: php3/configure.in diff -u php3/configure.in:1.493 php3/configure.in:1.494 --- php3/configure.in:1.493 Thu Jan 27 19:49:43 2000 +++ php3/configure.in Sun Jan 30 21:48:36 2000 @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.493 2000/01/27 18:49:43 sas Exp $ +dnl $Id: configure.in,v 1.494 2000/01/30 20:48:36 markonen Exp $ dnl Process this file with autoconf to produce a configure script. AC_INIT(main.c) @@ -803,6 +803,7 @@ else AC_ADD_LIBRARY(gd) AC_DEFINE(HAVE_LIBGD) + PHP_HAVE_GD=yes AC_MSG_RESULT(yes) fi ;; @@ -867,6 +868,7 @@ AC_MSG_RESULT(no) else AC_DEFINE(HAVE_LIBGD) + PHP_HAVE_GD=yes AC_MSG_RESULT(yes) fi else Index: php3/functions/gd.c diff -u php3/functions/gd.c:1.142 php3/functions/gd.c:1.143 --- php3/functions/gd.c:1.142 Mon Jan 24 21:07:49 2000 +++ php3/functions/gd.c Sun Jan 30 21:48:36 2000 @@ -29,7 +29,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.142 2000/01/24 20:07:49 eschmid Exp $ */ +/* $Id: gd.c,v 1.143 2000/01/30 20:48:36 markonen Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -105,6 +105,7 @@ {"imagecreatefrompng", php3_imagecreatefrompng, NULL}, {"imagepng", php3_imagepng, NULL}, #endif + {"imagewbmp", php3_imagewbmp, NULL}, {"imagedestroy", php3_imagedestroy, NULL}, {"imagefill", php3_imagefill, NULL}, {"imagefilledpolygon", php3_imagefilledpolygon, NULL}, @@ -936,6 +937,127 @@ } /* }}} */ #endif /* HAVE_GD_PNG */ + +/* {{{ proto int imagewbmp(int im [, string filename]) +Output wbmp image to browser or file */ +void php3_imagewbmp (INTERNAL_FUNCTION_PARAMETERS) { + pval *imgind, *file; + gdImagePtr im; + char *fn=NULL; + FILE *fp; + int argc; + int ind_type; + int output=1; + int x, y; + int c, p, width, height; + + GD_TLS_VARS; + + argc = ARG_COUNT(ht); + if (argc < 1 || argc > 2 || getParameters(ht, argc, &imgind, &file) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(imgind); + + 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, "ImageWbmp: Invalid filename"); + RETURN_FALSE; + } + } + + im = php3_list_find(imgind->value.lval, &ind_type); + if (!im || ind_type != GD_GLOBAL(le_gd)) { + php3_error(E_WARNING, "ImageWbmp: unable to find image pointer"); + RETURN_FALSE; + } + + if (argc == 2) { + fp = fopen(fn, "wb"); + if (!fp) { + php3_error(E_WARNING, "ImagePng: unable to open %s for writing", fn); + RETURN_FALSE; + } + + /* WBMP header, black and white, no compression */ + fputc(0,fp); fputc(0,fp); + + /* Width and height of image */ + c = 1; width = im->sx; + while(width & 0x7f << 7*c) c++; + while(c > 1) fputc(0x80 | (width >> 7*--c) & 0xff, fp); + fputc(width & 0x7f,fp); + c = 1; y = im->sy; + while(height & 0x7f << 7*c) c++; + while(c > 1) fputc(0x80 | (height >> 7*--c) & 0xff, fp); + fputc(height & 0x7f,fp); + + /* Actual image data */ + for(y = 0; y < im->sy; y++) { + p = c = 0; + for(x = 0; x < im->sx; x++) { +#if HAVE_GD_ANCIENT + if(im->pixels[x][y] == 0) c = c | (1 << (7-p)); +#else + if(im->pixels[y][x] == 0) c = c | (1 << (7-p)); +#endif + if(++p == 8) { + fputc(c,fp); + p = c = 0; + } + } + if(p) fputc(c,fp); + } + + fflush(fp); + fclose(fp); + } else { + output = php3_header(); + + if (output) { +#if APACHE && defined(CHARSET_EBCDIC) + /* This is a binary file already: avoid EBCDIC->ASCII conversion */ + ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0); +#endif + + /* WBMP header, black and white, no compression */ + php3_putc(0); php3_putc(0); + + /* Width and height of image */ + c = 1; width = im->sx; + while(width & 0x7f << 7*c) c++; + while(c > 1) php3_putc(0x80 | (width >> 7*--c) & 0xff); + php3_putc(width & 0x7f); + + c = 1; height = im->sy; + while(height & 0x7f << 7*c) c++; + while(c > 1) php3_putc(0x80 | (height >> 7*--c) & 0xff); + php3_putc(height & 0x7f); + + /* Actual image data */ + for(y = 0; y < im->sy; y++) { + p = c = 0; + for(x = 0; x < im->sx; x++) { +#if HAVE_GD_ANCIENT + if(im->pixels[x][y] == 0) c = c | (1 << (7-p)); +#else + if(im->pixels[y][x] == 0) c = c | (1 << (7-p)); +#endif + if(++p == 8) { + php3_putc(c); + p = c = 0; + } + } + if(p) php3_putc(c); + } + } + } + RETURN_TRUE; +} +/* }}} */ /* {{{ proto int imagesetpixel(int im, int x, int y, int col) Set a single pixel */ Index: php3/functions/php3_gd.h diff -u php3/functions/php3_gd.h:1.41 php3/functions/php3_gd.h:1.42 --- php3/functions/php3_gd.h:1.41 Thu Jan 13 14:31:11 2000 +++ php3/functions/php3_gd.h Sun Jan 30 21:48:36 2000 @@ -29,7 +29,7 @@ */ -/* $Id: php3_gd.h,v 1.41 2000/01/13 13:31:11 rasmus Exp $ */ +/* $Id: php3_gd.h,v 1.42 2000/01/30 20:48:36 markonen Exp $ */ #ifndef _PHP3_GD_H #define _PHP3_GD_H @@ -67,14 +67,21 @@ extern void php3_imagecolorresolve(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagecolorexact(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagecolorset(INTERNAL_FUNCTION_PARAMETERS); +extern void php3_imagecolortransparent(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagecolorstotal(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagecolorsforindex(INTERNAL_FUNCTION_PARAMETERS); -extern void php3_imagecolortransparent(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagecopy(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagecopyresized(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagecreate(INTERNAL_FUNCTION_PARAMETERS); +#if HAVE_GD_GIF extern void php3_imagecreatefromgif (INTERNAL_FUNCTION_PARAMETERS); +extern void php3_imagegif(INTERNAL_FUNCTION_PARAMETERS); +#endif +#if HAVE_GD_PNG extern void php3_imagecreatefrompng (INTERNAL_FUNCTION_PARAMETERS); +extern void php3_imagepng(INTERNAL_FUNCTION_PARAMETERS); +#endif +extern void php3_imagewbmp(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagedestroy(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagefill(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagefilledpolygon(INTERNAL_FUNCTION_PARAMETERS); @@ -82,9 +89,6 @@ extern void php3_imagefilltoborder(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagefontwidth(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagefontheight(INTERNAL_FUNCTION_PARAMETERS); -extern void php3_imagegammacorrect(INTERNAL_FUNCTION_PARAMETERS); -extern void php3_imagegif (INTERNAL_FUNCTION_PARAMETERS); -extern void php3_imagepng (INTERNAL_FUNCTION_PARAMETERS); extern void php3_imageinterlace(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imageline(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imageloadfont(INTERNAL_FUNCTION_PARAMETERS); @@ -95,9 +99,10 @@ extern void php3_imagestringup(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagesxfn(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagesyfn(INTERNAL_FUNCTION_PARAMETERS); +extern void php3_imagedashedline(INTERNAL_FUNCTION_PARAMETERS); +extern void php3_imagegammacorrect(INTERNAL_FUNCTION_PARAMETERS); extern void php3_free_gd_font(gdFontPtr); extern void _php3_gdimagecharup(gdImagePtr, gdFontPtr, int, int, int, int); -extern void php3_imagedashedline(INTERNAL_FUNCTION_PARAMETERS); #if HAVE_LIBTTF|HAVE_LIBFREETYPE extern void php3_imagettfbbox(INTERNAL_FUNCTION_PARAMETERS); extern void php3_imagettftext(INTERNAL_FUNCTION_PARAMETERS);

« previous php.dev (#15060) next »