Sometimes when I am trying to create blurred bitmap I am getting "Null Pointer Exception".
Happens in this block of code (I recently started catching the exception so at least it doesn't crash the app):
try
{
using (Bitmap.Config config = Bitmap.Config.Rgb565) {
return Bitmap.CreateBitmap (blurredBitmap, width, height, config);
}
}
catch (Java.Lang.Exception exception)
{
Util.Log(exception.ToString());
}
Please refer to these pictures for more details about parameters I am passing into the "CreateBitmap" method:
Here is the expanded parameters:
Full exception:
exception {Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown. at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2058/58099c53/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 at Android.Runtime.JNIEnv.CallStaticObjectMethod (IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00064] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1301 at Android.Graphics.Bitmap.CreateBitmap (System.Int32[] colors, Int32 width, Int32 height, Android.Graphics.Config config) [0x00088] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Graphics.Bitmap.cs:735 at Psonar.Apps.Droid.PayPerPlay.StackBlur.GetBlurredBitmap (Android.Graphics.Bitmap original, Int32 radius) [0x00375] in d:\Dev\psonar\Source\Psonar.Apps\Psonar.Apps.Droid\Psonar.Apps.Droid.PayPerPlay\Utilities\StackBlur.cs:123 --- End of managed exception stack trace --- java.lang.NullPointerException at android.graphics.Bitmap.createBitmap(Bitmap.java:687) at android.graphics.Bitmap.createBitmap(Bitmap.java:707) at dalvik.system.NativeStart.run(Native Method) } Java.Lang.NullPointerException
Not sure if this could be a bug in Xamarin or the passed parameters are wrong.