public IImage NewImage(string fileName, Framework.ImageFormat format) { //Handles options and configuration for the desired image Bitmap.Config config = null; switch (format) { case Framework.ImageFormat.ARGB4444: config = Bitmap.Config.Argb4444; format = Framework.ImageFormat.ARGB4444; break; case Framework.ImageFormat.ARGB8888: config = Bitmap.Config.Argb8888; format = Framework.ImageFormat.ARGB8888; break; case Framework.ImageFormat.RGB565: config = Bitmap.Config.Rgb565; format = Framework.ImageFormat.RGB565; break; } BitmapFactory.Options o = new BitmapFactory.Options(); o.InPreferredConfig = config; System.IO.Stream inStream = null; Bitmap bitmap = null; //Load the image from the assets folder try { inStream = assets.Open(fileName); bitmap = BitmapFactory.DecodeStream(inStream, null, o); if (bitmap == null) { throw new NullReferenceException("Couldn't load bitmap from assets '" + fileName + "'"); } } catch { throw new NullReferenceException("Couldn't load bitmap from assets '" + fileName + "'"); } finally { if (inStream != null) { try { inStream.Close(); } catch { } } } return(new AndroidImage(bitmap, format)); }
public AndroidImage(Bitmap bitmap, Framework.ImageFormat format) { this.bitmap = bitmap; this.format = format; }