Blur draw on Image view - android

I need to draw blur on image view and UnBlur also. I tried with RenderScript but I got full image blur,can any one help me regarding libraries or coding.Like below image
Thank you, enter image description here

This is a nice blurring library - https://github.com/500px/500px-android-blur
If you write a blurring function yourself, crop only the area you need by creating a new bitmap - Bitmap.createBitmap(sourceBitmap, startX, startY, width, height)

Related

Android how to stretch a particular section of a Image?

I am developing a photography app in which I want to select a particular section of a photo and stretch that portion only. How to do that?
I have tried to stretch a photo using Canvas but failed to do so. Is it possible from android.graphics.NinePatch class?
Any suggestions?
You can use matrix to apply new dimension to your bitmap.
you could use setscale/postScale methods of a matrix object.
A rather ugly solution would be using a image cropping library. You can use it to temporarily crop a portion of the image and load it into another ImageView and then scaling it up.
Also, you can get things done without using that CropImageView. The idea is whenever user touches the original image view, you will be given a (x, y) at which user's finger resides. So, you can extract a bitmap image centered at (x, y) and with a given radius.
For applying a magnifier effect you could use a round/circular ImageView for showing magnified portion of the image.
Something like this:
Finally i found a solution of my problem below :
Bitmap stretchImage = Bitmap.createBitmap(w, h+progress, Bitmap.Config.ARGB_8888 );
c = new Canvas(stretchImage);
//draw top bit
c.drawBitmap(normalImage, new Rect(0,0,w,75), new Rect(0,0,w,75), null);
//draw middle bit
c.drawBitmap(normalImage, new Rect(0,75,w, 150), new Rect(0,75,w,150+progress), null);
//draw right bit
c.drawBitmap(normalImage, new Rect(0 ,150,w,225), new Rect(0 ,150+progress,w,225+progress), null);
myImage.setImageBitmap(stretchImage);

How to make a background image fill the canvas?

Hello everyone I am new to android and I just have a quick question. I am making an animation using Bitmaps and drawing them to the canvas using the onDraw(). I am trying to draw a background to the canvas that I made in photoshop. I already uploaded it as a drawable and then decoded it to a Bitmap then added it to the onDraw method. It draws, but I doesn't fill the entire canvas like I want it to. Any suggestions and or fixes? Thank you so much, I looked around and saw something about converting the bitmap to an image view but didn't really understand all to well.
Use drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) where the rect for source is the entire bitmap (from 0,0 to width, height) and dest is the entire canvas. This will stretch the bitmap to fill the canvas. Be warned this can cause the aspect ratio to be off and/or issues with fuzziness or blockiness.

Crop a triangle from an image, using its center in android

How can I crop a triangle from an image (given the degree) using it's center.
for e.g. In the below image, fig_1 is the original image. I want to cut it like fig_2, fig_3 and fig_4 where, x, y and z are the degree of the angles.
Any help would be appreciated. Thanks.
Not sure if this is the best solution but you might want to use the BitMap class. First write the contents of the image to a Buffer, then use copyPixelsFromBuffer(Buffer) in BitMap class to get a BitMap. Then write the logic to edit the BitMap, e.g. you can use eraseColor(int). Then copy your edited BitMap to an ImageView using setImageBitMap(BitMap) method in ImageView class.

How to create a transparent bitmap / drawable in android using drawing lines and circles on a canvas

It seems to be a very trivial thing, but I am not able to find a sample code for it.
I am trying to do a very simple thing. On a canvas I plan to draw a round rect and save that in a drawable which I can then set as a background of a button.
Now I am looking for 2 things, how to draw and create a round rect so that the transparency effect can be created (like in a png drawable)
Second how to save the canvas to an image.
Please help
Please try to use this code.
Bitmap bitmap=BitmapFactory.decodeResource(getResources(),R.color.transparant);
canvas.drawBitmap(bitmap, matrix, paint);

Android Freehand bitmap cropping

I know we can crop a bitmap in rectangular shape using:
Bitmap.createBitmap(source, x, y, width, height)
But I want to know to crop a bitmap in freehand mode or some polygon shape. Its best example can be seen in Jigsaw Puzzle game
I have spent a lot of time googling about this but found no help. Can anybody help me in this regard?
You can use a Path to determine a clip area on your Canvas when drawing a Bitmap.
For a full example see:
Android - Crop an image from multipoints
and also:
Cutting a multipoint ploygon out of Bitmap and placing it on transparency

Categories

Resources