开发者

System.ArgumentException when calling MediaLibrary.SavePicture()

开发者 https://www.devze.com 2023-02-07 08:28 出处:网络
My code looks like this: String filename = Utils.GetNextFilename(); Med开发者_运维技巧iaLibrary library = new MediaLibrary();

My code looks like this:

String filename = Utils.GetNextFilename();
Med开发者_运维技巧iaLibrary library = new MediaLibrary();
library.SavePicture(filename, corrected_image);

And in the SavePicture() call, I get the following:

An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.Xna.Framework.dll

Additional information: Value does not fall within the expected range.

But I'm not sure why.


Okay, I figured it out. I must reset the stream:

String filename = Utils.GetNextFilename();
MediaLibrary library = new MediaLibrary();
corrected_image.Seek(0, 0);                      // <-- The fix.
library.SavePicture(filename, corrected_image);
0

精彩评论

暂无评论...
验证码 换一张
取 消