cureos / aforge

PCL version of AForge.NET Framework, https://code.google.com/p/aforge/
Other
125 stars 96 forks source link

Bitmap.FromStream hangs #15

Closed buraktamturk closed 9 years ago

buraktamturk commented 9 years ago

Hello,

I want to create Bitmap from MemoryStream. But whatever i use from FileStream or MemoryStream, I got hang after calling Bitmap.FromStream.

MemoryStream ms = new MemoryStream();
new FileStream("/Users/buraktamturk/test.jpg", FileMode.Open).CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);

Bitmap b = (Bitmap)Bitmap.FromStream(ms);

OS: OS X Runtime: mono or dnvm (whichever is right)

I think I have a problem with integration, cause when i try it on Windows. I get following exception instead of hang.

BitmapImage has not been initialized.  Call the BeginInit method, set the appropriate properties, and then call the EndInit method.

Thanks, Burak

Edit: Not only MemoryStream, but also FileStream.

anders9ustafsson commented 9 years ago

Thanks for reporting, Burak! Which platform are you targeting, iOS? I don't recognize the error message right away, but I will look deeper into the issue within the next few days. Best regards, Anders @ Cureos

buraktamturk commented 9 years ago

Thank you, actually I am targetting vnext web project Windows for production, OS X for development. (web application) The runtime is dnvm runtime but i belive it uses mono on OS X because it needs mono to run. in os x the function hangs, in windows i get the exception message "BitmapImage has not been initialized."

You do not have to look at this issue because I managed to import System.Drawing to that project at least on Windows, so my code is working at least on Windows and i can use virtual machine while i am developing. Thanks again!

anders9ustafsson commented 9 years ago

If you are working with ASP.NET, it is probably better to use the original AForge libraries, where you (at least on Windows) should have access to the real System.Drawing assembly. I am no Mono expert, but isn't there System.Drawing for Mono, too? If you use the original libraries (see here), I think you should be able to work it out even on Mac OS X.