G
Guest
Thanks to BMermuys I can now copy data from an unmanage
Array to a Managed Array as I do in dbl_read
My -maybe stupid- question
How does it work the other way around
You can see what I tried in dbl_write
How to do the Marshal Copy to my Pointe
or how to get a Pointer to my data[] Array
I tried Marshal.StructureToPtr, &, and Marshal.Copy bu
none worked
Thanks in Advanc
Marti
using System
using System.Runtime.InteropServices
namespace Dickenbestimmun
/// <summary
/// Summary description for FileIO
/// </summary
public class FileI
public int maxindex
public int canFloat
public int[] resolution
public float[] length
public double[][][] VoxelData
double[] data
IntPtr pData = IntPtr.Zero
[DllImport("OMASLIB.DLL", SetLastError=true)
public static extern int omas_dbl_write
[MarshalAs(UnmanagedType.LPStr)] string fname
[In, Out] int[] res
[In, Out] float[] len
ref IntPtr data
int canFloat)
public int dbl_write(string fname
//Marshal.Copy ( data, pData, 0, maxindex )
int result = omas_dbl_write( fname, resolution, length, ref pData, canFloat )
return result
[DllImport("OMASLIB.DLL", SetLastError=true)
public static extern int omas_dbl_read
[MarshalAs(UnmanagedType.LPStr)] string fname
[In, Out] int[] res
[In, Out] float[] len
ref IntPtr data)
public int dbl_read(string fname
int result = 0
resolution = new int[] {0,0,0,0}
length = new float[] {0,0,0,0 }
canFloat = omas_dbl_read( fname, resolution, length, ref pData )
maxindex = resolution[0]* resolution[1] * resolution[2]* resolution[3]; // calculate _number of elements_ in dat
data = new double[maxindex]
Marshal.Copy ( pData, data, 0, maxindex )
return canFloat
public FileIO(
/
// TODO: Add constructor logic her
/
Array to a Managed Array as I do in dbl_read
My -maybe stupid- question
How does it work the other way around
You can see what I tried in dbl_write
How to do the Marshal Copy to my Pointe
or how to get a Pointer to my data[] Array
I tried Marshal.StructureToPtr, &, and Marshal.Copy bu
none worked
Thanks in Advanc
Marti
using System
using System.Runtime.InteropServices
namespace Dickenbestimmun
/// <summary
/// Summary description for FileIO
/// </summary
public class FileI
public int maxindex
public int canFloat
public int[] resolution
public float[] length
public double[][][] VoxelData
double[] data
IntPtr pData = IntPtr.Zero
[DllImport("OMASLIB.DLL", SetLastError=true)
public static extern int omas_dbl_write
[MarshalAs(UnmanagedType.LPStr)] string fname
[In, Out] int[] res
[In, Out] float[] len
ref IntPtr data
int canFloat)
public int dbl_write(string fname
//Marshal.Copy ( data, pData, 0, maxindex )
int result = omas_dbl_write( fname, resolution, length, ref pData, canFloat )
return result
[DllImport("OMASLIB.DLL", SetLastError=true)
public static extern int omas_dbl_read
[MarshalAs(UnmanagedType.LPStr)] string fname
[In, Out] int[] res
[In, Out] float[] len
ref IntPtr data)
public int dbl_read(string fname
int result = 0
resolution = new int[] {0,0,0,0}
length = new float[] {0,0,0,0 }
canFloat = omas_dbl_read( fname, resolution, length, ref pData )
maxindex = resolution[0]* resolution[1] * resolution[2]* resolution[3]; // calculate _number of elements_ in dat
data = new double[maxindex]
Marshal.Copy ( pData, data, 0, maxindex )
return canFloat
public FileIO(
/
// TODO: Add constructor logic her
/