CVS update: php3/functions
| From: | thies | Date: | Sun, 02 May 1999 15:27:42 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-5332@lists.php.net to get a copy of this message | ||
Date: Sunday May 2, 1999 @ 11:27
Author: thies
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv27976/functions
Modified Files:
image.c
Log Message:
added bits and channels to GetImageSize
Index: php3/functions/image.c
diff -u php3/functions/image.c:1.47 php3/functions/image.c:1.48
--- php3/functions/image.c:1.47 Fri Jan 22 16:42:32 1999
+++ php3/functions/image.c Sun May 2 11:27:42 1999
@@ -26,7 +26,7 @@
| Authors: Rasmus Lerdorf |
+----------------------------------------------------------------------+
*/
-/* $Id: image.c,v 1.47 1999/01/22 21:42:32 rasmus Exp $ */
+/* $Id: image.c,v 1.48 1999/05/02 15:27:42 thies Exp $ */
/*
* Based on Daniel Schmitt's imageinfo.c which carried the following
* Copyright notice.
@@ -74,6 +74,8 @@
struct gfxinfo {
unsigned int width;
unsigned int height;
+ unsigned int bits;
+ unsigned int channels;
};
/* routine to handle GIF files. If only everything were that easy... ;} */
@@ -82,7 +84,7 @@
struct gfxinfo *result = NULL;
unsigned char a[2];
- result = (struct gfxinfo *) emalloc(sizeof(struct gfxinfo));
+ result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
fseek(fp, 6L, SEEK_SET);
fread(a,sizeof(a),1,fp);
result->width = (unsigned short)a[0] | (((unsigned short)a[1])<<8);
@@ -108,7 +110,7 @@
struct gfxinfo *result = NULL;
unsigned long in_width, in_height;
- result = (struct gfxinfo *) emalloc(sizeof(struct gfxinfo));
+ result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
fseek(fp, 16L, SEEK_SET);
in_width = php3_read4(fp);
in_height = php3_read4(fp);
@@ -223,7 +225,6 @@
{
struct gfxinfo *result = NULL;
unsigned int marker=0;
- unsigned short in_width, in_height;
fseek(fp, 0L, SEEK_SET); /* position file pointer on SOF */
@@ -251,15 +252,15 @@
case M_SOF15:
if (result == NULL) {
/* handle SOFn block */
- fseek(fp, 3L, SEEK_CUR); /* skip length and precision bytes */
- in_height = php3_read2(fp);
- in_width = php3_read2(fp);
- /* fill a gfxinfo struct to return the data */
- result = (struct gfxinfo *) emalloc(sizeof(struct gfxinfo));
+ result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
- result->width = (unsigned int) in_width;
- result->height = (unsigned int) in_height;
+ fseek(fp, 2, SEEK_CUR);
+ result->bits = fgetc(fp);
+ result->height = php3_read2(fp);
+ result->width = php3_read2(fp);
+ result->channels = fgetc(fp);
+
if (! info) /* if we don't want an extanded info -> return */
return result;
} else {
@@ -381,8 +382,16 @@
add_index_long(return_value, 0, result->width);
add_index_long(return_value, 1, result->height);
add_index_long(return_value, 2, itype);
+
sprintf(temp, "width=\"%d\" height=\"%d\"", result->width,
result->height); /* safe */
add_index_string(return_value, 3, temp, 1);
+
+ if (result->bits != 0) {
+ add_assoc_long(return_value,"bits",result->bits);
+ }
+ if (result->channels != 0) {
+ add_assoc_long(return_value,"channels",result->channels);
+ }
efree(result);
}
--
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