1

In one of my app i need to make a bitmap's portion blurred...

I need to allow the user to figure move and make that portion of bitmap blur.

How to apply this?? if it is possible? and if yes then how????

I have visited This site but not fruitful output

How can I do this?Is it possible?

I have done this:

mPaint.setAlpha(10);
            // mPaint.setStyle(Style.FILL);
            //mPaint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
            mPaint.setMaskFilter(new BlurMaskFilter(30, BlurMaskFilter.Blur.INNER));
             paint.setStyle(Style.STROKE);
            mPaint.setAntiAlias(true);

            mPaint.setAntiAlias(true);
            mPath = new Path();
            mPath.offset(30, 30);

            paths.add(new PathPoints(mPath, color, false, strokWidth));
            mCanvas = new Canvas();
            c2 = new Canvas();

            // this.setDrawingCacheEnabled(true);
            c2.setBitmap(Transparent);

and

protected void onDraw(Canvas canvas1) {
            canvas = canvas1;

            // === canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);

            canvas.drawBitmap(Transparent, 0, 0, mBitmapPaint);
            c2.drawBitmap(Bitmap2, 0, 0, mBitmapPaint);
            // canvas.drawBitmap(Transparent, 0, 0, mBitmapPaint);
            // canvas.drawBitmap(Transparent, 0, 0, null);
            // c2.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
            for (PathPoints p : paths) {

                //mPaint.setColor(p.getColor());
                mPaint.setStrokeWidth(p.getStrokWidth());
                Log.v("", "Color code : " + p.getColor());
                if (p.isTextToDraw()) {
                    canvas.drawText(p.textToDraw, p.x, p.y, mPaint);
                } else {
                    // if(isTouched)
                    // {
                    // canvas.drawPath(p.getPath(), mPaint);
                    c2.drawPath(p.getPath(), mPaint);


                }

            }
            //
            // invalidate();

        }
Community
  • 1
  • 1
Android
  • 8,995
  • 9
  • 67
  • 108

1 Answers1

1

The idea here is not that complex. You create statically a blurred version of your image (Renderscript maybe?) then you draw the original image on the canvas. At this point when the user touches the canvas you draw in the touched area a portion of the blurred bitmap. To achieve this you might want to try some PorterDuff masking in order to make it look nice (like having an alpha mask to draw the blurred part in order to blend it better with the original image).

Pasquale Anatriello
  • 2,355
  • 1
  • 16
  • 16
  • 1
    porter duff: http://www.techrepublic.com/article/punch-a-hole-in-a-bitmap-by-using-androids-porter-duff-xfer/ Blurring http://developer.xamarin.com/recipes/android/other_ux/drawing/blur_an_image_with_renderscript/ – Pasquale Anatriello Aug 11 '14 at 12:06
  • thanks for helping but i want touch smooth blur i mean user touch that part of bitmap should blur only other remain unchanged. – Android Aug 11 '14 at 12:17
  • I understood that. Please read carefully the full response. To achieve that you need a bit of work... – Pasquale Anatriello Aug 11 '14 at 12:18