Changeset 13459
- Timestamp:
- 12/28/07 20:49:15 (6 months ago)
- Files:
-
- branches/1.5/gdal/swig/csharp/apps/GDALOverviews.cs (modified) (3 diffs)
- branches/1.5/gdal/swig/include/csharp/gdal_csharp.i (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.5/gdal/swig/csharp/apps/GDALOverviews.cs
r11217 r13459 24 24 { 25 25 Console.WriteLine("usage: gdaloverviews {GDAL dataset name} {resamplealg} {level1} {level2} ...."); 26 Console.WriteLine("example: gdaloverviews sample.tif \"NEAREST\" 2 4"); 26 27 System.Environment.Exit(-1); 27 28 } … … 64 65 levels[i-2] = int.Parse(args[i]); 65 66 } 66 if (ds.BuildOverviews(args[1], levels ) != (int)CPLErr.CE_None)67 if (ds.BuildOverviews(args[1], levels, new Gdal.GDALProgressFuncDelegate(ProgressFunc), "Sample Data") != (int)CPLErr.CE_None) 67 68 { 68 69 Console.WriteLine("The BuildOverviews operation doesn't work"); … … 98 99 } 99 100 } 101 102 public static int ProgressFunc(double Complete, IntPtr Message, IntPtr Data) 103 { 104 Console.Write("Processing ... " + Complete * 100 + "% Completed."); 105 if (Message != IntPtr.Zero) 106 Console.Write(" Message:" + System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Message)); 107 if (Data != IntPtr.Zero) 108 Console.Write(" Data:" + System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Data)); 109 110 Console.WriteLine(""); 111 return 1; 112 } 100 113 } branches/1.5/gdal/swig/include/csharp/gdal_csharp.i
r13112 r13459 9 9 10 10 %include typemaps_csharp.i 11 12 %pragma(csharp) modulecode="public delegate int GDALProgressFuncDelegate(double Complete, IntPtr Message, IntPtr Data);" 13 14 %typemap(imtype) (GDALProgressFunc callback) "$module.GDALProgressFuncDelegate" 15 %typemap(cstype) (GDALProgressFunc callback) "$module.GDALProgressFuncDelegate" 16 %typemap(csin) (GDALProgressFunc callback) "$csinput" 17 %typemap(in) (GDALProgressFunc callback) %{ $1 = ($1_ltype)$input; %} 18 %typemap(imtype) (void* callback_data) "string" 19 %typemap(cstype) (void* callback_data) "string" 20 %typemap(csin) (void* callback_data) "$csinput" 11 21 12 22 %define %rasterio_functions(GDALTYPE,CSTYPE) … … 92 102 /*! Sixty four bit floating point */ %ds_rasterio_functions(DataType.GDT_Float64,double) 93 103 94 public int BuildOverviews( string resampling, int[] overviewlist ) {104 public int BuildOverviews( string resampling, int[] overviewlist, $module.GDALProgressFuncDelegate callback, string callback_data) { 95 105 int retval; 96 106 if (overviewlist.Length <= 0) … … 100 110 try { 101 111 Marshal.Copy(overviewlist, 0, ptr, overviewlist.Length); 102 retval = BuildOverviews(resampling, overviewlist.Length, ptr, null, null);112 retval = BuildOverviews(resampling, overviewlist.Length, ptr, callback, callback_data); 103 113 } finally { 104 114 Marshal.FreeHGlobal(ptr); … … 106 116 GC.KeepAlive(this); 107 117 return retval; 118 } 119 public int BuildOverviews( string resampling, int[] overviewlist) { 120 return BuildOverviews( resampling, overviewlist, null, null); 108 121 } 109 122 }
