[Mono-dev] Remoting IplImage/Bitmap return type problem

Euan MacInnes euan_macinnes at hotmail.com
Sat Nov 24 23:06:06 EST 2007

Hi Mauricio,
     One option to do this is to extract the bitmap as a series of bytes, and then stream the byte array across.

given a bitmap called "mybitmap"

MemoryStream ms = New MemoryStream();
mybitmap.Save(ms,  ImageFormat.Jpeg);  // Save it as Jpeg if you don't mind it being compressed

then you can either serialise the stream, or convert to an array of bytes and send that: 

byte[] picBuf = ms.GetBuffer();



> Date: Sat, 24 Nov 2007 20:12:15 -0300
> From: buhochileno at gmail.com
> To: mono-devel-list at lists.ximian.com
> Subject: [Mono-dev] Remoting IplImage/Bitmap return type problem
> Hi:
> I still have my problem about how to get the remoting object picture 
> from a client. First I try to make a property and a method to return a 
> Bitmap, but finally I only get "some class/type is not marked as 
> Serializable...", and now I try to use a IplImage from a basic OpenCv 
> implementation that I have for mono based on the SharpCV wrapper (yes, 
> the wrapper use IntPtr and DllImport native calls :-S. With my IplImage 
> test I allmost succed, in the client side I can make the asignation to a 
> local copy of the image, something like this:
> CvImage frame = remOrbitKit.Video.LastIplFrame; //-> this is the remote 
> object property that return a "CvImage" picture type
> ..this work...
> ..but if I later try to show the image the applicatio crash with this:
> Unhandled Exception: System.NotSupportedException: Unsupported primitive 
> type: System.IntPtr
> Server stack trace:
>   at 
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WritePrimitiveValue 
> (System.IO.BinaryWriter writer, System.Object value) [0x001b4] in 
> /mnt/data/opt/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:898
>   at 
> System.Runtime.Serialization.Formatters.Binary.MessageFormatter.WriteMethodResponse 
> (System.IO.BinaryWriter writer, System.Object obj, 
> System.Runtime.Remoting.Messaging.Header[] headers, ISurrogateSelector 
> surrogateSelector, StreamingContext context, FormatterAssemblyStyle 
> assemblyFormat, FormatterTypeStyle typeFormat) [0x00191] in 
> /mnt/data/opt/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs:237
>   at 
> System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize 
> (System.IO.Stream serializationStream, System.Object graph, 
> System.Runtime.Remoting.Messaging.Header[] headers) [0x00061] in 
> /mnt/data/opt/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:226
> I know that this may sound to a specific opencv or image question, but I 
> only want to know how can I traslate picture information with remoting, 
> I also know that may be this is not recomended due the large amount of 
> binary info..but I only need this for test porpuses, so bitmap, mpeg, 
> jpg, other streaming approach??.
> in advance, thank you very much.
> Mauricio
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list