I'm working on an application in which I'v a custom ImageView. Using custom imageview I can drag,zoom, and paste text over over it (using its onDraw() function). Now at the end I want to put all the canvas drawing over image and want to save it in the file system. I have tried imageView.getDrawingCache() method but it does not fulfill my requirements as when I zoom out the it captures black sides of the image too. Any suggestions?
Create or load your Bitmap.
Create Canvas.
Set the Bitmap as target for this canvas. link
Draw your text using the canvas.
Now your image stored in Bitmap has drawn stuff on top of it.
Related
enter image description hereI am using Canvas to draw circles and lines. I want to display small circles inside the canvas in particular position. For that, i have created a circular drawable xml file and i have converted that xml into Bitmap and displaying over the Canvas and for that i am using canvas.drawBitmap() method.
But i want to display a textview inside that Bitmap but textview is getting displayed above that Bitmap using canvas.drawText(). I want to display the text inside the Bitmap.
You can use TextDrawable library, and found it to be very useful.This light-weight library provides images with letter/text like the Gmail app.
It extends the Drawable class thus can be used with existing/custom/network ImageView classes. Also included is a fluent interface for creating drawables and a customizable ColorGenerator.
Click here for example on github
Forget Canvas, draw an xml.
First convert text in svg on line i.e :
_ https://framavectoriel.org/ (only 4 police)
_ https://www.janvas.com/v6.1/janvas_app_6.1_public/index.html (not free)
Secondly, convert svg in xml here :
http://a-student.github.io/SvgToVectorDrawableConverter.Web/
And then, you have your text in a bitmap
*If you don't know how to save the svg on framavectoriel.org, click on the button, copy the lines and save it with svg extension.
Can I upload a picture (in a ImageView) and draw rectangles using the canvas in the same ImageView? all the examples I've seen so far used two. I wonder if you can use only one? if so, how?
If you are new to android.
Open android studio, .
File ->New->import Sample ,
search for image.
Choose basic render script, this will give you basics of image handling.
However for your usage, you can simply create a view with border and add imageview inside it.
I want to blur the specific part of image in android without using Render Script. I am using minSdkVersion 14. I want to make image blur dynamically like image processing apps do. Dynamically means there should be one movable view on top of image and inside that view, Image will be clear and other than that it should be blurred.
You should first blur the bitmap:
Android: fast bitmap blur?
Then you have to apply image masking to that bitmap by using transparent in the middle.
Masking(crop) image in frame
Then you should put this bitmap as drawale to your movable imageview.
I want to add a free hand crop functionality.
Till now I can open the picture and draw a path around the part of the image that I want to crop thanks to this code:
https://stackoverflow.com/a/18459072/2361533
But before opening the cropped image in another activity, I want to darken the outside part of the crop path, to show the user how the cropped image will be. In case he does not like the result, he could reset the image.
It would be something like the image here:
Android: Free Croping of Image
How can i do this ?
Use the following two methods as a start:
setXfermode(new PorterDuffXfermode(Mode.DARKEN));
canvas.clipPath(path, Region.Op.DIFFERENCE);
The first one is applied to a Paint object and darkens a certain region.
The second "clips" the path in your canvas and takes the inverse (using Region.Op.DIFFERENCE).
I have a bitmap and a text-view.
I want to draw the bitmap over the text-view. But the issue I am facing is that I do not have the canvas of the text-view.
I know, I can wrap the bitmap into a drawable & set it as the background of the text-view like discussed in this post - Set Bitmap as background of Text View - Android.
But, I do not want to convert my bitmap into a drawable. I want it to be able to directly draw the bitmap onto the text-view.
I know, I can create a custom text-view class, by extending text-view, and over-ride the onDraw() method of the class, where-in I will get the associated canvas as the parameter, over which I can draw the bitmap, as described here - http://developer.android.com/guide/topics/graphics/2d-graphics.html
But, I am working on some legacy-code, and so, do not want to convert the text-view object into a custom text-view one.
If anybody has worked in this area before, please help !