简体   繁体   English

如何用另一个可绘制区域填充imageView中的可绘制区域?

[英]How to fill the drawable region in an imageView with another drawable?

so I'm trying to find the region of the current image in the ImageView and fill that region with a different image. 因此,我试图在ImageView中查找当前图像的区域,并用其他图像填充该区域。 Here is the original image Empty Circle inside an imageView . 这是imageView内的原始图像Empty Circle The imageView has a drawable of a circle inside. imageView内部有一个可绘制的圆形。 Then I'm trying to make it into something like this Circle filled with image inside an ImageView when a user chooses an image. 然后,当用户选择图像时,我试图将其变成类似这样的圆,在ImageView中填充图像。 I don't want to manually Photoshop a circle image. 我不想手动用Photoshop制作圆形图像。 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 . 我已经尝试了AlphaComposite SRC_IN方法,但是对于android,我无法从BitMap转换为graphics2D If anyone knows how to solve this using the BitmapFactory in android, I would really appreciate your help. 如果有人知道如何使用android中的BitmapFactory解决此问题,我将非常感谢您的帮助。 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. 要将该圆形/形状图像另存为png,并且要填充的区域是透明的,然后将其设置为ImageView(等)的可绘制区域,然后在RelativeLayout中将此视图放置在要填充该区域的图像上并将透明背景应用于形状视图,或者只需将填充图像设置为形状视图的背景即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM