diff options
author | Uwe Steinmann <steinm@php.net> | 2000-03-28 16:45:05 +0000 |
---|---|---|
committer | Uwe Steinmann <steinm@php.net> | 2000-03-28 16:45:05 +0000 |
commit | cdb7254384a4014e0edf397afb524c9116116937 (patch) | |
tree | e818e86ce90a8950539d00b7e5072fab56a735ed /ext/pdf | |
parent | a4de43fe87133c028fb20bfde4c7da7eff16963d (diff) | |
download | php-git-cdb7254384a4014e0edf397afb524c9116116937.tar.gz |
- added pdf_open_image_file() to read jpeg, tiff, gif and png images
Diffstat (limited to 'ext/pdf')
-rw-r--r-- | ext/pdf/pdf.c | 78 | ||||
-rw-r--r-- | ext/pdf/php_pdf.h | 2 |
2 files changed, 76 insertions, 4 deletions
diff --git a/ext/pdf/pdf.c b/ext/pdf/pdf.c index eb03b63aee..1181d1e24a 100644 --- a/ext/pdf/pdf.c +++ b/ext/pdf/pdf.c @@ -145,10 +145,12 @@ function_entry pdf_functions[] = { 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 @@ PHP_FUNCTION(pdf_open_gif) { 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,41 @@ PHP_FUNCTION(pdf_open_jpeg) { 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"); + RETURN_FALSE; + } + + id = zend_list_insert((void *) pdf_image,PDF_GLOBAL(le_pdf_image)); + RETURN_LONG(id); +} +/* }}} */ + +/* {{{ 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"); @@ -2211,7 +2247,42 @@ PHP_FUNCTION(pdf_open_tiff) { RETURN_FALSE; } - pdf_image = PDF_open_TIFF(pdf, arg2->value.str.val); + 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_image_file(pdf, arg2->value.str.val, arg3->value.str.val, "", 0); if(pdf_image < 0) { php_error(E_WARNING, "Could not open image"); @@ -2270,7 +2341,6 @@ PHP_FUNCTION(pdf_open_memory_image) { } } - pdf_image = PDF_open_image(pdf, "raw", "memory", buffer, im->sx*im->sy*3, im->sx, im->sy, 3, 8, NULL); efree(buffer); diff --git a/ext/pdf/php_pdf.h b/ext/pdf/php_pdf.h index c0840f2f54..8d0975e96c 100644 --- a/ext/pdf/php_pdf.h +++ b/ext/pdf/php_pdf.h @@ -115,10 +115,12 @@ PHP_FUNCTION(pdf_set_transition); 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); |