[GRASS-SVN] r58119 - in grass/branches/develbranch_6/lib: gis pngdriver
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Oct 29 06:34:07 PDT 2013
Author: martinl
Date: 2013-10-29 06:34:06 -0700 (Tue, 29 Oct 2013)
New Revision: 58119
Modified:
grass/branches/develbranch_6/lib/gis/gdal.c
grass/branches/develbranch_6/lib/pngdriver/read_png.c
grass/branches/develbranch_6/lib/pngdriver/write_png.c
Log:
#2095 (GRASS changes for OSGeo4W 64bit)
patch provided by jef
Modified: grass/branches/develbranch_6/lib/gis/gdal.c
===================================================================
--- grass/branches/develbranch_6/lib/gis/gdal.c 2013-10-29 01:33:59 UTC (rev 58118)
+++ grass/branches/develbranch_6/lib/gis/gdal.c 2013-10-29 13:34:06 UTC (rev 58119)
@@ -91,6 +91,7 @@
"libgdal1.7.0.so",
# endif
# ifdef _WIN32
+ "gdal110.dll",
"gdal19.dll",
"gdal18.dll",
"gdal17.dll",
@@ -120,7 +121,7 @@
{
load_library();
-# ifdef _WIN32
+# if defined(_WIN32) && !defined(_WIN64)
pGDALAllRegister = get_symbol("_GDALAllRegister at 0");
pGDALOpen = get_symbol("_GDALOpen at 8");
pGDALClose = get_symbol("_GDALClose at 4");
Modified: grass/branches/develbranch_6/lib/pngdriver/read_png.c
===================================================================
--- grass/branches/develbranch_6/lib/pngdriver/read_png.c 2013-10-29 01:33:59 UTC (rev 58118)
+++ grass/branches/develbranch_6/lib/pngdriver/read_png.c 2013-10-29 13:34:06 UTC (rev 58119)
@@ -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 @@
if (!input)
G_fatal_error("PNG: couldn't open output file %s", file_name);
- png_init_io(png_ptr, input);
+ png_set_read_fn(png_ptr, input, read_data);
png_read_info(png_ptr, info_ptr);
Modified: grass/branches/develbranch_6/lib/pngdriver/write_png.c
===================================================================
--- grass/branches/develbranch_6/lib/pngdriver/write_png.c 2013-10-29 01:33:59 UTC (rev 58118)
+++ grass/branches/develbranch_6/lib/pngdriver/write_png.c 2013-10-29 13:34:06 UTC (rev 58119)
@@ -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 @@
if (!output)
G_fatal_error("PNG: couldn't open output file %s", 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,
width, height, 8,
More information about the grass-commit
mailing list