Re: ArgumentException received when converting a byte array to bitmap
From: Frank Hileman (frankhil_at_no.spamming.prodigesoftware.com)
Date: 08/18/04
- Next message: mattaku: "Re: ArgumentException received when converting a byte array to bit"
- Previous message: Jorge Ribeiro: "Reducing image size dynamicaly"
- In reply to: mattaku: "RE: ArgumentException received when converting a byte array to bitmap"
- Next in thread: mattaku: "Re: ArgumentException received when converting a byte array to bit"
- Reply: mattaku: "Re: ArgumentException received when converting a byte array to bit"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 17 Aug 2004 17:10:06 -0700
The stream for a Bitmap should never be closed. This was probably the source
of your error. The rotations probably disconnected the Bitmap from the
stream, by creating a copy.
Regards,
Frank Hileman
check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
"mattaku" <mattaku@discussions.microsoft.com> wrote in message
news:169FEFC2-DEA7-4CA6-B9D1-E67E0A81A379@microsoft.com...
> Hah! I just had this problem and posted something on it. I read on
another
> thread that rotating an image helped them with a similar, but different
bug.
> Here is a snippet of my code that now works:
>
> byte[] byteArray = Convert.FromBase64String( base64String );
> MemoryStream memStrm = new MemoryStream( byteArray, 0, byteArray.Length );
> retObj = Image.FromStream( memStrm );
>
> // these next two lines is to fix a weird C#/.Net bug
> ((Image)retObj).RotateFlip( RotateFlipType.Rotate180FlipNone );
> ((Image)retObj).RotateFlip( RotateFlipType.Rotate180FlipNone );
>
> memStrm.Close();
>
> Why it works, I don't know. I think it is a .Net bug myself. Try it and
> see. Hope this solution isn't too late for your problem.
- Next message: mattaku: "Re: ArgumentException received when converting a byte array to bit"
- Previous message: Jorge Ribeiro: "Reducing image size dynamicaly"
- In reply to: mattaku: "RE: ArgumentException received when converting a byte array to bitmap"
- Next in thread: mattaku: "Re: ArgumentException received when converting a byte array to bit"
- Reply: mattaku: "Re: ArgumentException received when converting a byte array to bit"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|