[mono-android] Retrieving an image from Assets
Jonathan Pryor
jonp at xamarin.com
Mon Feb 27 17:19:38 UTC 2012
On Feb 26, 2012, at 9:54 PM, tcorrigan5 wrote:
> I have placed a .png file in Assets but get the following error when I attempt to retrieve it using the following code:
> var input = Assets.Open("theImage.png");
> The variable input that is returned in this case is an Android.Runtime.InputStreamInvoker
If an instance is returned, then it sounds like `Assets.Open("theIMage.png")` is working properly. What's the error, other than that the Length and Position properties aren't supported?
If you want to convert the stream into a Bitmap, use BitmapFactory.DecodeStream(Stream):
http://androidapi.xamarin.com/monodoc.ashx?link=M%3aAndroid.Graphics.BitmapFactory.DecodeStream(System.IO.Stream)
- Jon
More information about the Monodroid
mailing list