Re: [IronPython] Convert between python array and .NET Array

2010-06-15 Thread Marcel
Ok, it's clear now. Thanks for the great support! -- Marcel On Jun 15, 9:21 pm, Dino Viehland wrote: > Marcel wrote: > > Thanks Dino, the ctypes.memmove does work! > > > I wasn't aware that ctypes could be used in IronPython. Do they > > marshal to unmanaged code under the hood? > > There's not

Re: [IronPython] Convert between python array and .NET Array

2010-06-15 Thread Curt Hagenlocher
On Tue, Jun 15, 2010 at 9:21 PM, Dino Viehland wrote: > > For the 2 IntPtr cases there's no overloads on Marshal and I don't believe > anywhere in .NET. Yes, this is my mistake. I think I saw the [IntPtr[], int, IntPtr, int] overload and mentally elided the first array specifier. -Curt _

Re: [IronPython] Convert between python array and .NET Array

2010-06-15 Thread Dino Viehland
Marcel wrote: > Thanks Dino, the ctypes.memmove does work! > > I wasn't aware that ctypes could be used in IronPython. Do they > marshal to unmanaged code under the hood? There's not really any unmanaged code on *our* side involved at all. It all turns into .NET's support for interop. So we'll

Re: [IronPython] Convert between python array and .NET Array

2010-06-15 Thread Marcel
mmove(0, bytes, total_bytes) > > > > > -Original Message- > > From: users-boun...@lists.ironpython.com [mailto:users- > > boun...@lists.ironpython.com] On Behalf Of Marcel > > Sent: Monday, June 14, 2010 6:21 PM > > To: us...@lists.ironpython.com > >

Re: [IronPython] Convert between python array and .NET Array

2010-06-15 Thread Dino Viehland
From: users-boun...@lists.ironpython.com [mailto:users- > boun...@lists.ironpython.com] On Behalf Of Marcel > Sent: Monday, June 14, 2010 6:21 PM > To: users@lists.ironpython.com > Subject: Re: [IronPython] Convert between python array and .NET Array > > Hi Curt, > > I did try that ove

Re: [IronPython] Convert between python array and .NET Array

2010-06-14 Thread Marcel
Hi Curt, I did try that overload but I get this quite amusing error message: TypeError: Copy() takes at least 2147483647 arguments (4 given) Without the explicit overload selection, I get: TypeError: expected IntPtr, got int Did the example work for you with the overload you suggested? The reas

Re: [IronPython] Convert between python array and .NET Array

2010-06-14 Thread Curt Hagenlocher
Ah, I'm clearly not familiar with how the array type was implemented. The first member of the buffer_info() tuple is an IntPtr, so you probably want the [IntPtr, int, IntPtr, int] overload of Marshal.Copy. In fact, if you use the buffer_info() approach, you may be able to avoid manually specifying

Re: [IronPython] Convert between python array and .NET Array

2010-06-13 Thread Marcel
Hi Curt, Your suggestion gives me: TypeError: expected Array[Byte], got array bytes is a Python array. I tried: Marshal.Copy.Overloads[Array[Byte], int, IntPtr, int] (bytes.buffer_info()[0], 0, bmData.Scan0, total_bytes) but that gave the error: TypeError: expected Array[Byte], got int This sma

Re: [IronPython] Convert between python array and .NET Array

2010-06-12 Thread Curt Hagenlocher
It looks like the automatic overload resolution may be failing -- at least, it's worth trying to resolve the overload manually. This would be something like from System import Array, Byte, IntPtr Marshal.Copy.Overloads[Array[Byte], int, IntPtr, int](bytes, 0, bmData.Scan0, total_bytes) On Sat, J

Re: [IronPython] Convert between python array and .NET Array

2010-06-12 Thread Marcel
I think I simplified my example a little too far. I'm trying to display a Bitmap from bytes generated in Python code. bytes = array.array('c') # tried 'B' also # generate bitmap bytes ... bitmap = Bitmap(width, height, PixelFormat.Format24bppRgb) bmData = bitmap.L

Re: [IronPython] Convert between python array and .NET Array

2010-06-11 Thread David Escobar
This worked for me (based on the code you provided): import clr from System import Array dest = Array[str](bytes) On Fri, Jun 11, 2010 at 9:51 PM, Marcel wrote: > I have a python method that returns a Python byte array.array('c'). > > Now, I want to copy this array using > System.Runtime.Inte

[IronPython] Convert between python array and .NET Array

2010-06-11 Thread Marcel
I have a python method that returns a Python byte array.array('c'). Now, I want to copy this array using System.Runtime.InteropServices.Marshal.Copy. This method however expects a .NET Array. import array from System.Runtime.InteropServices import Marshal bytes = array.array('c') bytes.append('a