Browse Source

https://trac.osgeo.org/grass/ticket/2095 (GRASS changes for OSGeo4W 64bit)
patch provided by jef


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58120 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 11 years ago
parent
commit
483249fee7
3 changed files with 59 additions and 4 deletions
  1. 23 1
      lib/pngdriver/read_png.c
  2. 34 2
      lib/pngdriver/write_png.c
  3. 2 1
      lib/raster/gdal.c

+ 23 - 1
lib/pngdriver/read_png.c

@@ -6,6 +6,28 @@
 #include <grass/gis.h>
 #include "pngdriver.h"
 
+static void read_data(png_structp png_ptr, png_bytep data, png_size_t length)
+{
+  png_size_t check;
+  FILE *fp;
+
+  if (png_ptr == NULL )
+    return;
+
+  fp = (FILE *) png_get_io_ptr(png_ptr);
+
+  if ( fp == NULL )
+    return;
+
+  /* fread() returns 0 on error, so it is OK to store this in a png_size_t
+   * instead of an int, which is what fread() actually returns.
+   */
+  check = fread(data, 1, length, fp);
+
+  if (check != length)
+    G_fatal_error("PNG: Read Error");
+}
+
 void read_png(void)
 {
     static jmp_buf jbuf;
@@ -34,7 +56,7 @@ void read_png(void)
     if (!input)
 	G_fatal_error("PNG: couldn't open output file %s", png.file_name);
 
-    png_init_io(png_ptr, input);
+    png_set_read_fn(png_ptr, input, read_data);
 
     png_read_info(png_ptr, info_ptr);
 

+ 34 - 2
lib/pngdriver/write_png.c

@@ -1,4 +1,3 @@
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <png.h>
@@ -6,6 +5,39 @@
 #include <grass/gis.h>
 #include "pngdriver.h"
 
+
+static void write_data(png_structp png_ptr, png_bytep data, png_size_t length)
+{
+    png_size_t check;
+    FILE *fp;
+
+    if (png_ptr == NULL )
+	return;
+
+    fp = (FILE *) png_get_io_ptr(png_ptr);
+    if ( fp == NULL )
+        return;
+
+    check = fwrite(data, 1, length, fp);
+
+    if (check != length)
+	G_fatal_error("PNG: Write Error");
+}
+
+static void output_flush(png_structp png_ptr)
+{
+    FILE *fp;
+
+    if (png_ptr == NULL )
+	return;
+
+    fp = (FILE *) png_get_io_ptr(png_ptr);
+    if ( fp == NULL )
+	return;
+
+    fflush( fp );
+}
+
 void write_png(void)
 {
     static jmp_buf jbuf;
@@ -34,7 +66,7 @@ void write_png(void)
     if (!output)
 	G_fatal_error("PNG: couldn't open output file %s", png.file_name);
 
-    png_init_io(png_ptr, output);
+    png_set_write_fn(png_ptr, output, write_data, output_flush);
 
     png_set_IHDR(png_ptr, info_ptr,
 		 png.width, png.height, 8,

+ 2 - 1
lib/raster/gdal.c

@@ -114,6 +114,7 @@ static void load_library(void)
 	"libgdal1.7.0.so",
 # endif
 # ifdef _WIN32
+	"gdal110.dll",
 	"gdal19.dll",
 	"gdal18.dll",
 	"gdal17.dll",
@@ -143,7 +144,7 @@ static void init_gdal(void)
 {
     load_library();
 
-# ifdef _WIN32
+# if defined(_WIN32) && !defined(_WIN64)
     pGDALAllRegister = get_symbol("_GDALAllRegister@0");
     pGDALOpen = get_symbol("_GDALOpen@8");
     pGDALClose = get_symbol("_GDALClose@4");