cvs: /php4/ext/pdf pdf.c php_pdf.h

From: Date: Tue, 28 Mar 2000 16:45:35 +0000
Subject: cvs: /php4/ext/pdf pdf.c php_pdf.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-12749@lists.php.net to get a copy of this message
steinm Tue Mar 28 08:45:35 2000 EDT Modified files: /php4/ext/pdf pdf.c php_pdf.h Log: - added pdf_open_image_file() to read jpeg, tiff, gif and png images Index: php4/ext/pdf/pdf.c diff -u php4/ext/pdf/pdf.c:1.31 php4/ext/pdf/pdf.c:1.32 --- php4/ext/pdf/pdf.c:1.31 Thu Mar 9 06:53:29 2000 +++ php4/ext/pdf/pdf.c Tue Mar 28 08:45:04 2000 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdf.c,v 1.31 2000/03/09 14:53:29 steinm Exp $ */ +/* $Id: pdf.c,v 1.32 2000/03/28 16:45:04 steinm Exp $ */ /* pdflib 2.01 is subject to the ALADDIN FREE PUBLIC LICENSE. Copyright (C) 1997 Thomas Merz. */ @@ -145,10 +145,12 @@ PHP_FE(pdf_set_duration, NULL) PHP_FE(pdf_open_jpeg, NULL) PHP_FE(pdf_open_tiff, NULL) + PHP_FE(pdf_open_png, NULL) #if HAVE_LIBGD13 PHP_FE(pdf_open_memory_image, NULL) #endif PHP_FE(pdf_open_gif, NULL) + PHP_FE(pdf_open_image_file, NULL) PHP_FE(pdf_close_image, NULL) PHP_FE(pdf_place_image, NULL) PHP_FE(pdf_add_weblink, NULL) @@ -2143,7 +2145,7 @@ RETURN_FALSE; } - pdf_image = PDF_open_GIF(pdf, arg2->value.str.val); + pdf_image = PDF_open_image_file(pdf, "gif", arg2->value.str.val, "", 0); if(pdf_image < 0) { php_error(E_WARNING, "Could not open image"); @@ -2177,7 +2179,7 @@ RETURN_FALSE; } - pdf_image = PDF_open_JPEG(pdf, arg2->value.str.val); + pdf_image = PDF_open_image_file(pdf, "jpeg", arg2->value.str.val, "", 0); if(pdf_image < 0) { php_error(E_WARNING, "Could not open image"); @@ -2189,6 +2191,40 @@ } /* }}} */ +/* {{{ proto int pdf_open_png(int pdf, string pngfile) + Opens a png file and returns an image for placement in a pdf document */ +PHP_FUNCTION(pdf_open_png) { + pval *arg1, *arg2; + int id, type; + int pdf_image; + PDF *pdf; + PDF_TLS_VARS; + + if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(arg2); + id=arg1->value.lval; + pdf = zend_list_find(id,&type); + if(!pdf || type!=PDF_GLOBAL(le_pdf)) { + php_error(E_WARNING,"Unable to find file identifier %d",id); + RETURN_FALSE; + } + + pdf_image = PDF_open_image_file(pdf, "png", arg2->value.str.val, "", 0); + + if(pdf_image < 0) { + php_error(E_WARNING, "Could not open image"); + RETURN_FALSE; + } + + id = zend_list_insert((void *) pdf_image,PDF_GLOBAL(le_pdf_image)); + RETURN_LONG(id); +} +/* }}} */ + /* {{{ proto int pdf_open_tiff(int pdf, string tifffile) Opens a tiff file and returns an image for placement in a pdf document */ PHP_FUNCTION(pdf_open_tiff) { @@ -2210,8 +2246,43 @@ php_error(E_WARNING,"Unable to find file identifier %d",id); RETURN_FALSE; } + + pdf_image = PDF_open_image_file(pdf, "tiff", arg2->value.str.val, "", 0); + + if(pdf_image < 0) { + php_error(E_WARNING, "Could not open image"); + RETURN_FALSE; + } + + id = zend_list_insert((void *) pdf_image,PDF_GLOBAL(le_pdf_image)); + RETURN_LONG(id); +} +/* }}} */ + +/* {{{ proto int pdf_open_image_file(int pdf, string type, string file) + Opens an image file of the given type and returns an image for placement in a pdf document */ +PHP_FUNCTION(pdf_open_image_file) { + pval *arg1, *arg2, *arg3; + int id, type; + int pdf_image; + PDF *pdf; + PDF_TLS_VARS; + + if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(arg1); + convert_to_string(arg2); + convert_to_string(arg3); + id=arg1->value.lval; + pdf = zend_list_find(id,&type); + if(!pdf || type!=PDF_GLOBAL(le_pdf)) { + php_error(E_WARNING,"Unable to find file identifier %d",id); + RETURN_FALSE; + } - pdf_image = PDF_open_TIFF(pdf, arg2->value.str.val); + pdf_image = PDF_open_image_file(pdf, arg2->value.str.val, arg3->value.str.val, "", 0); if(pdf_image < 0) { php_error(E_WARNING, "Could not open image"); @@ -2269,7 +2340,6 @@ *ptr++ = im->blue[color]; } } - pdf_image = PDF_open_image(pdf, "raw", "memory", buffer, im->sx*im->sy*3, im->sx, im->sy, 3, 8, NULL); efree(buffer); Index: php4/ext/pdf/php_pdf.h diff -u php4/ext/pdf/php_pdf.h:1.6 php4/ext/pdf/php_pdf.h:1.7 --- php4/ext/pdf/php_pdf.h:1.6 Sat Feb 26 03:58:48 2000 +++ php4/ext/pdf/php_pdf.h Tue Mar 28 08:45:04 2000 @@ -26,7 +26,7 @@ | Authors: Uwe Steinmann | +----------------------------------------------------------------------+ */ -/* $Id: php_pdf.h,v 1.6 2000/02/26 11:58:48 steinm Exp $ */ +/* $Id: php_pdf.h,v 1.7 2000/03/28 16:45:04 steinm Exp $ */ #ifndef _PHP_PDF_H #define _PHP_PDF_H @@ -115,10 +115,12 @@ PHP_FUNCTION(pdf_set_duration); PHP_FUNCTION(pdf_open_jpeg); PHP_FUNCTION(pdf_open_tiff); +PHP_FUNCTION(pdf_open_png); #if HAVE_LIBGD13 PHP_FUNCTION(pdf_open_memory_image); #endif PHP_FUNCTION(pdf_open_gif); +PHP_FUNCTION(pdf_open_image_file); PHP_FUNCTION(pdf_close_image); PHP_FUNCTION(pdf_place_image); PHP_FUNCTION(pdf_put_image);

« previous php.version4 (#12749) next »