Hello,
I need to convert a Byte array back into an image. If I do that in the Unity IDE it is working but if I do it after I compiled it in windows it is not working anymore.
I am converting the Byte array into a Stream and try to convert the Stream into an image afterwards.
Stream tempstream;
System.Drawing.Image tempimage = null;
try{
Byte[] ba;
ba = (Byte[]) reader["FlagPng"];
Debug.Log ("ByteArray: "+ba.ToString ());
tempstream = new MemoryStream(ba);
Debug.Log ("tempstream: "+tempstream.ToString ());
tempimage = Image.FromStream(tempstream);
}
catch(Exception ex){
Debug.LogError ("Errormessage 100:
"+ex.Message );
Debug.LogError ("Errorsource 100:
"+ex.Source );
Debug.LogError ("Errorstacktrace 100:
"+ex.StackTrace);
Debug.LogError ("Errortargetsite 100:
"+ex.TargetSite);
}
In my output_log is written:
ByteArray: System.Byte
tempstream: System.IO.MemoryStream
Errormessage 100:
Could not load type ‘System.IO.InternalBufferOverflowException’ from assembly ‘System.Drawing’.
Errorsource 100:
System.Drawing
Errorstacktrace 100:
at System.Drawing.Image.InitFromStream (System.IO.Stream stream) [0x00000] in :0
at System.Drawing.Image.LoadFromStream (System.IO.Stream stream, Boolean keepAlive) [0x00000] in :0
at System.Drawing.Image.FromStream (System.IO.Stream stream) [0x00000] in :0
at SQLDatabase.ReadTblLanguages () [0x00000] in :0
Errortargetsite 100:
IntPtr InitFromStream(System.IO.Stream)
I can tell that the problem should be the line:
tempimage = Image.FromStream(tempstream);
All dlls I am using are mono dlls from the library directory of Unity.
Can anyone tell me how I can convert a stream into an image in Unity?
Thank you in advance.