[mapserver-commits] r10339 - sandbox/mapserver6

svn at osgeo.org svn at osgeo.org
Fri Jul 9 10:50:58 EDT 2010


Author: tbonfort
Date: 2010-07-09 14:50:58 +0000 (Fri, 09 Jul 2010)
New Revision: 10339

Modified:
   sandbox/mapserver6/mapimageio.c
Log:
use filename for opening images (try to fix osx bug)


Modified: sandbox/mapserver6/mapimageio.c
===================================================================
--- sandbox/mapserver6/mapimageio.c	2010-07-09 13:59:53 UTC (rev 10338)
+++ sandbox/mapserver6/mapimageio.c	2010-07-09 14:50:58 UTC (rev 10339)
@@ -673,13 +673,17 @@
     return MS_SUCCESS;
 }
 
-int readPNG(FILE *stream, rasterBufferObj *rb) {
+int readPNG(char *path, rasterBufferObj *rb) {
     png_uint_32 width,height,row_bytes;
     int bit_depth,color_type,i;
     unsigned char **row_pointers;
     png_structp png_ptr = NULL;
     png_infop info_ptr = NULL;
     
+    FILE *stream = fopen(path,"rb");
+    if(!stream)
+    	return MS_FAILURE;
+
     /* could pass pointers to user-defined error handlers instead of NULLs: */
     png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
     if (!png_ptr)
@@ -752,7 +756,7 @@
     png_read_end(png_ptr,NULL);
     png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
     
-
+    fclose(stream);
     return MS_SUCCESS; 
 
 }
@@ -916,7 +920,7 @@
 
 /* not fully implemented and tested */
 /* missing: set the first pointer to a,r,g,b */
-int readGIF(FILE *stream, rasterBufferObj *rb)
+int readGIF(char *path, rasterBufferObj *rb)
 {
    int i, j, codeSize, extCode, firstImageRead = MS_FALSE;
    unsigned char *r,*g,*b,*a;
@@ -931,7 +935,7 @@
 
 
    rb->type = MS_BUFFER_BYTE_RGBA;
-   image =  DGifOpenFileHandle(fileno(stream));
+   image =  DGifOpenFileName(path);
    if (image == NULL) {
 	  msSetError(MS_MISCERR,"failed to load gif image: %s","readGIF()", gif_error_msg());
       return MS_FAILURE;
@@ -1113,15 +1117,15 @@
         return MS_FAILURE;
     }
     fread(signature,1,8,stream);
-    rewind(stream);
+    fclose(stream);
     if(png_check_sig(signature,8)) {
-         ret = readPNG(stream,rb);
+         ret = readPNG(path,rb);
     } else if (!strncmp((char*)signature,"GIF",3)) {
-       ret = readGIF(stream,rb);
+
+       ret = readGIF(path,rb);
     } else {
         msSetError(MS_MISCERR,"unsupported pixmap format","readImage()");
         return MS_FAILURE;
     }
-    fclose(stream);
     return ret;
 }



More information about the mapserver-commits mailing list