so I'm trying to find the region of the current image in the ImageView and fill that region with a different image. Here is the original image Empty Circle inside an imageView. The imageView has a drawable of a circle inside. Then I'm trying to make it into something like this Circle filled with image inside an ImageView when a user chooses an image. I don't want to manually Photoshop a circle image. I am just hoping to fill the region with another image. I have tried SRC_IN method from AlphaComposite, but for android, I can't convert from BitMap to graphics2D. If anyone knows how to solve this using the BitmapFactory in android, I would really appreciate your help. Thank you.
The other solution besides Bitmaps, may be too simple for whatever you are trying to achieve otherwise I think it would have occurred to you. I'm just pointing it out in case you have "code blindness" and are trying to over-engineer the solution because you've worked on it for too long (we've all done it)
It is to have that circle/shape image saved as a png with the area you want filled being transparent then set it as the drawable for an ImageView (etc.) then in a RelativeLayout lay this view over the image you want to fill the area and apply a transparent background to the shape view OR simply set the fill image as the background for the shape view.
Related
App State right now
I am making an app in which i want the background scenery/picture to be visible in the black sketch only and the reset of the part of the image should stay opaque. Right now i have made front Imageview transparent to some value but that is not what i want ,i want to change the opacity of black pixels only.
ImageView frontImageView = findViewById(R.id.image);
Bitmap front = BitmapFactory.decodeResource(getResources(),
R.drawable.front);
front=GrayscaleToBin(front);
front.setHasAlpha(true);
frontImageView.setImageBitmap(front);
imageView.setImageAlpha(150);
i have searched a lot but couldn't find a solution to this problem. Any help is appreciated.
I would recommend to make changes in original image from some other tools such as Paint or Photoshop etc and then load image in app.
Since making changes on current image which you are having will again take some time to load unnecessary.
Better process image in other 3rd party tool and use as it is in app.
I have a frame image and another image selected from gallery. What i want is to place that image inside the transparent part of that frame image and also I can apply onTouchListener on the image selected from gallery.
Like in the app whose link is provided following.
https://play.google.com/store/apps/details?id=com.lyrebirdstudio.pipcamera
Any idea or concept will be helpful.
My IDEA
Here is what i am thinking to create a relative layout and setting the Picture Frame as a background and then scaling the other image according to the size of the relative layout. Then i can apply onTouchlistener on the image easily.
Am i going in right direction or there is some better way though which i can achieve the desire results?
Thanks in advance.
http://stacktips.com/tutorials/android/how-to-drag-a-view-in-android
OR
how to drag an image by touching in android?
hope it helps..
In my app I am getting image from URL and showing in an ImageView. I get a circle shape(blue color) image which is in a square(white color) background. I want to show my image just as a circle ..How to remove or hide the extra white color in that image within my app?
Below is the image for reference:
You should first remove the white part of image in an image editor like Photoshop or Gimp. Making background transparent won't work because white part is not background, It's in image.
Alternatively, You can create a round Imageview if you want your square images to be shown as circular (e.g. profile pictures on Google+). There is a working code snippet here for rounded ImageView How to create a circular ImageView in Android?
Alternatively, if you don't want to use this snippet, you can use a library that will make it easy to create rounded ImageViews. see this
https://github.com/vinc3m1/RoundedImageView
I want to get the part of an image which is visible to us. There is another image over the first image. So from that image, some part of first image is visible. And I want that part only.
I’ll show you sample of it and final output which I am expecting from it.
I know how to crop in oval shape. But here, the template used in above example can be different in actual, so as per the template /mask I need to crop that image.
How can I do this. Any idea?
A simple but maybe not very efficient solution:
assume the mask is above the real image
both images are in the same container and if the mask is above the image this means that the pixels of the image would correspond to pixels of the mask
draw only those pixels of the image whose corresponding pixel in the mask is not black
Is there any way to create a bitmap that, when you use it in on a view in the setImageBitmap method, it looks like no image was actually set at all?
EDIT: To clarify, I want the bitmap to not be visible, or it can be visible, as long as its nothing, as long as the user cant see it im happy.
EDIT2: I cannot use setVisibility because my ImageView also has a setBackground attribute that I want to remain visible. If I set the view to invisible, the background AND the bitmap image are affected, and I dont want that. I only want the bitmap image to be invisible.
You could call imageView.setImageBitmap(null) to remove the current image and keep the background.
You could make a 1x1 pixel bitmap which is nothing but empty canvas (in photoshop perhaps), then use the draw9patch tool to make it stretch.
EDIT: If you just need it not to draw, you can call setVisibility(View.INVISIBLE) on the view like so:
imageView.setVisibilty(View.INVISIBLE)
← Image is here
above is a 50X50 transparent image created in photoshop download and use it,