Hello all, I have to blur an image and I have implemented my own blur
algorithm (gaussian), but it is too slow (I guess it is due to the
emulator and the interpreted nature of the Dalvik VM).

I have found the class android.graphics.BlurMaskFilter but I haven't
been able to apply it successfully to an image (Bitmap).

If I try something like:

        Paint blurPaint = new Paint();
        blurPaint.setFilterBitmap(true);
        blurPaint.setMaskFilter(new BlurMaskFilter(radius,
BlurMaskFilter.Blur.NORMAL));

        Bitmap blurred = Bitmap.createBitmap(800, 600,
Bitmap.Config.RGB_565);
        Canvas c = new Canvas(blurred);
        c.drawBitmap(originalBitmap, 0, 0, blurPaint);

nothing happens (well, the borders of the image appear with shade,
with seems normal, according to "Note: if the paint contains a
maskfilter that generates a mask which extends beyond the bitmap's
original width/height (e.g. BlurMaskFilter), then the bitmap will be
drawn as if it were in a Shader with CLAMP mode. "

But the image is not blurred!!

I have tried a different approach passing the image to grey scale, the
grey to the alpha channel (because there is only a extractAlpha()
method that takes a Paint) and then:

Bitmap blurredBitmap = bm.extractAlpha(blurPaint, new int[] {0, 0});

But it makes the VM crash!! (seems like a bug inside the
extractAlpha() method, because extractAlpha() without params also
crash). It crashes when I use Bitmap.Config.ARGB_8888 or
Bitmap.Config.ARGB_4444, but not if I use Bitmap.Config.RGB_565, but
then obviously I lose the alpha information and the resulting bitmap
is all black.

Could anybody please provide a working example of blurring an image?

Thanks in advance,

Jose Luis.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to