Problem with byte[] and images?

2009-04-09 Thread VSmirk
I am finding a problem with the serialization and deserialization of image files in my .Net application. The deserialized image is not a valid GIF image, and will not display. I have been able to determine that the problem comes down to an odd insertion of characters just before the byte[] eleme

Re: Problem with byte[] and images?

2009-04-09 Thread Marc Gravell
OK; I'm investigating now... As an aside - if you are going to read the entire file, you might as well use File.ReadAllBytes(path) - it'll be a lot easier. I'll see what I can find out... Marc Gravell --~--~-~--~~~---~--~~ You received this message because you are

Re: Problem with byte[] and images?

2009-04-09 Thread Marc Gravell
Simple fix - you are asking it to save the gif **as a protobuf**, which means it'll include a few extra things (like a dummy field and a length prefix). Simply replace the line (incorrect): Serializer.Serialize(targetImage,img2.ImageJPGData); with (correct): File.WriteAllBytes(targetIma

Re: Problem with byte[] and images?

2009-04-09 Thread Marc Gravell
Oops - slight error in my reply! Here's the *working* code ;-p using (Stream gpkFile = File.OpenRead(Path.Combine(folderPath, String.Format("{0}.gpk", image.ImageName { Image img2 = Serializer.Deserialize(gpkFile); } string path2 = Path.Combine(folderPath, "b_" + image.Ima

Re: Problem with byte[] and images?

2009-04-09 Thread VSmirk
Thank god for simple problems. Thanks for the quick response and the good catch. I'm not sure how long it would have taken me to go through all of your source code before going back and comparing types in each serialize call! On Apr 9, 9:28 am, Marc Gravell wrote: > Oops - slight error in my r

Re: Protobuf-net Serialize problem

2009-04-09 Thread test.f...@nomail.please
Marc, We figured out the problem. I had to send it over TIBCO as byte[] and on the server side, it had to be pulled out as tibrv_u8array. After that, the protobuf string conversion worked. However, I noticed couple of odd things in this latest release of protobuf-net. 1) It seems that an Option

Re: Protobuf-net Serialize problem

2009-04-09 Thread test.f...@nomail.please
Marc, ACtually, not using detectMissing will fix the string serialization but not the primitive types which would default to default(T). How will protobuf-net serialize the field if I munged the signature as public int? Foo { get; set; } Thanks --~--~-~--~~~---~--~-