image - New warning in Android 4.4 -
I have seen these exceptions recently (those who have been caught but are logged into log-in):
W / System.err (2612): java.lang.RuntimeException: Canvas on android.graphics.Canvas.throwIfCannotDraw: a non premultiplied bitmap android.graphics.Bitmap@535924e0 w / Systemkerr (2612) trying to use (Canvas.java:1088) W / System.err (2612): android.graphics.Canvas & lt; Init & gt; (Canvas.java:139) System.err (2612) :. Com.example.imaging.ImageHelper at addShadow (ImageHelper.java:553) is
I understand this exception means (as well as non-premultiplied bitmaps), but I'm not sure whether this exception may cause I've tried it. Are we having problems with the pictures we are receiving from the server or are we doing something locally? (This is not just the line that causes exception, but it is one of them).
For reference, I have added method in question and highlights that which causes an exception:
public static bitmap addShadow (Bitmap bitmap) { Try {BlurMaskFilter blurFilter = New BlurMaskFilter (12, BlurMaskFilter.Blur.OUTER); Paint shadowPaint = new paint (); ShadowPaint.setMaskFilter (blurFilter); ShadowPaint.setShadowLayer (12, -3, -3, Color. Parsi Color ("# 33000000")); Int [] offsetXY = new int [2]; Bitmap shadow image = bitmap Extract alpha (photopont, offset xy); Bitmap Shadow Iamaz 32 = Shadow Image.Copy (bitmap config.argb_8888, true); Canvas C = new canvas (shadow image 32); // Exception occurs here & lt; ---- c.drawBitmap (bitmap, offset xy [0], -offet xy [1], blank); Return Choice Image 32; } Hold (exception e) {e.printStackTrace (); } Return Bitmap; // If the error is the original bitmap}
I am facing a single problem In the exact same code, but I have to solve it in the Android code, do not replace images outside of the app because I am using the images loaded with the user's device.
What I did is found to be the following, before calling canvas :
// Fix a non-pre-fold state. If (ShadowImage32.isprimultiplied ()) {shadowImage32.setPremultiplied (true); }
The problem here is that my minimum API level 10, and Hapramitl () API requires 17 and Setprimaltipid (true) < / Em> need API1. Edit
When: I API is tested using a device with 10 and this is no exception, so I think the API first former-times 9 Handling exception. So, finally, I address these lines:
// API to set exceptions in non pre-multiplied by 19 + if (android.os.build.VERSION.SDK_INT & gt ; = 1 9 & amp; ShadowImage32.isprimultiplied ()) {shadowImage32.setPremultiplied (true); }
Comments
Post a Comment