So I am trying to develop an animation that fills a png into white like this:
For the transparent woman, I have a custom view that draws the png, and an AsyncTask for the animation that calls the view's invalidate() method.
I was able to draw and animate almost everything, but I cannot find a solution for filling the png from bottom to top. How can I create a "mask" that draws exactly the shape of the woman in white from bottom to top?
Related
I have a swing GUI app, which is basically an image editor but I have issues when implementing zooming functionality and finding the position of the mouse/cursor relative to the image.
I have a canvas (JPanel) and an image (BufferedImage).
The image is drawn in such a way, so that the image appears centered on the canvas, the math for getting the mouse position relative to the image was quite simple, simply subtract the space between the image "origin" and the canvas origin:
However, what happens when the "image" is scaled, drawn on a smaller portion of the canvas? Smaller like this, for example:
How would I get the position of the mouse, relative the canvas and make it relative to the image inside the canvas instead?
Thanks in advance.
How do I make part of an image view selectable with a resizable rectangle? (like the crop functionality) .
the image view:
EDIT:
I have successfully drawn a rectangle on the image view,by using canvas. how do I make the drawn rectangle dragable by the user?
I suggest you to extend the ImageView. You can have a Rect variable in your class which you can use to determine the cropping area. Than you can override onTouchmethod to handle touch events to manipulate the cropping rectangle and override the onDrawto draw the cropping area over bitmap.
There is also this cropper library you can use to avoid all the hard work by the way. https://github.com/edmodo/cropper
I'm trying to put corners im my ImageView and I find these "workarounds":
1 - Take the Bitmap soure and paint then
2 - put a second ImageView on my layout and use shape+corners as its source
It's not possible take the image view and put a corner around then?
In my app i have a List with a lot of ImageView (the Bitmap used in this ImageView's is programmatically) and I want to put corners in every ImageView.
There is any other option?
You can create a selector that contains shape with rounded corners, and then apply it as the ImageView's background using xml.
Look at this answers here
You can also do it via code by using PorterDuffXfermode. PorterDuffXfermode uses alpha compositing that will allow you to create and intersection (things of mathematical sets here) between the Canvas you get from onDraw() and an off screen Canvas you will have to create. You will use one of the PorterDuff.Mode flags to tell the framework you want to only render the pixels that intersect from the two Bitmaps in each Canvas.
More on Alpha Compositing
I'm looking for an automatic way to grab a piece of a bitmap and extract a certain part of it.
Let me explain:
If I have this image:
http://imgur.com/B9U9E
It has a big white border. (see link for better white result) I'm looking for a way to only grab the dialog above. So no white borders around the dialog. Is there a way to do this by code or with a library?
You should know that the image could have any form and positioned anywhere on the white dialog.
So a user draws something on the white panel and i need the program to automatically make a rectangle about where the users drew on the canvas and save that bitmap where the user drew on the canvas (Everything in between that rectangle).
Pseudocode
Define the background color.
Scan from the left, right, bottom, top and store the locations of the transitions from background to drawing.
The rectangle defined by (left, bottom) and (right, top) defines the cropping area
For a Java code example, please see: How to auto crop an image white border in Java?
Look into Bitmap.createBitmap.
I have png images of map tiles over parts of the UK and i want to draw them on top of the google maps view, I have everytyhing set up, just want to be able to draw the tile images now.
My main class extends 'MapActivity', can i add a canvas function to draw them?
ALso, I only obviously need to draw the tiles that are in view on the phone while the tiles out of view should not be drawn.
You can add an Overlay to the MapView, that will get you a canvas to draw on. See http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/Overlay.html