Changeset 13458
- Timestamp:
- 12/28/07 20:32:54 (6 months ago)
- Files:
-
- trunk/gdal/swig/csharp/apps/GDALOverviews.cs (modified) (3 diffs)
- trunk/gdal/swig/include/csharp/gdal_csharp.i (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/swig/csharp/apps/GDALOverviews.cs
r13437 r13458 54 54 { 55 55 Console.WriteLine("usage: gdaloverviews {GDAL dataset name} {resamplealg} {level1} {level2} ...."); 56 Console.WriteLine("example: gdaloverviews sample.tif \"NEAREST\" 2 4"); 56 57 System.Environment.Exit(-1); 57 58 } … … 94 95 levels[i-2] = int.Parse(args[i]); 95 96 } 96 if (ds.BuildOverviews(args[1], levels) != (int)CPLErr.CE_None) 97 98 if (ds.BuildOverviews(args[1], levels, new Gdal.GDALProgressFuncDelegate(ProgressFunc), "Sample Data") != (int)CPLErr.CE_None) 97 99 { 98 100 Console.WriteLine("The BuildOverviews operation doesn't work"); … … 128 130 } 129 131 } 132 133 public static int ProgressFunc(double Complete, IntPtr Message, IntPtr Data) 134 { 135 Console.Write("Processing ... " + Complete * 100 + "% Completed."); 136 if (Message != IntPtr.Zero) 137 Console.Write(" Message:" + System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Message)); 138 if (Data != IntPtr.Zero) 139 Console.Write(" Data:" + System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Data)); 140 141 Console.WriteLine(""); 142 return 1; 143 } 130 144 } trunk/gdal/swig/include/csharp/gdal_csharp.i
r13436 r13458 35 35 36 36 %include typemaps_csharp.i 37 38 %pragma(csharp) modulecode="public delegate int GDALProgressFuncDelegate(double Complete, IntPtr Message, IntPtr Data);" 39 40 %typemap(imtype) (GDALProgressFunc callback) "$module.GDALProgressFuncDelegate" 41 %typemap(cstype) (GDALProgressFunc callback) "$module.GDALProgressFuncDelegate" 42 %typemap(csin) (GDALProgressFunc callback) "$csinput" 43 %typemap(in) (GDALProgressFunc callback) %{ $1 = ($1_ltype)$input; %} 44 %typemap(imtype) (void* callback_data) "string" 45 %typemap(cstype) (void* callback_data) "string" 46 %typemap(csin) (void* callback_data) "$csinput" 37 47 38 48 %define %rasterio_functions(GDALTYPE,CSTYPE) … … 118 128 /*! Sixty four bit floating point */ %ds_rasterio_functions(DataType.GDT_Float64,double) 119 129 120 public int BuildOverviews( string resampling, int[] overviewlist ) {130 public int BuildOverviews( string resampling, int[] overviewlist, $module.GDALProgressFuncDelegate callback, string callback_data) { 121 131 int retval; 122 132 if (overviewlist.Length <= 0) … … 126 136 try { 127 137 Marshal.Copy(overviewlist, 0, ptr, overviewlist.Length); 128 retval = BuildOverviews(resampling, overviewlist.Length, ptr, null, null);138 retval = BuildOverviews(resampling, overviewlist.Length, ptr, callback, callback_data); 129 139 } finally { 130 140 Marshal.FreeHGlobal(ptr); … … 132 142 GC.KeepAlive(this); 133 143 return retval; 144 } 145 public int BuildOverviews( string resampling, int[] overviewlist) { 146 return BuildOverviews( resampling, overviewlist, null, null); 134 147 } 135 148 }
