如何从原始位图的一部分制作新的圆形位图?
我有一张从相机捕获的位图。我可以在位图上放置一个透明圆圈。我想做的是将圆圈的像素制作成一个新的单独的圆形位图。我有一个针对圆圈像素的算法,但如何将这些像素复制到另一个形状为圆形且具有圆圈大小的位图中?
public void findCirclePixels(){
for (int i=centreX-50; i < centreX+50; ++i) {
for (int y=centreY-50; y <centreY+50 ; ++y) {
if( Math.sqrt( Math.pow(i - centreX, 2) + ( Math.pow(y - centreY, 2) ) ) <= radius ){
bgr.setPixel(i,y,Color.rgb(Progress+50,Progress,Progress+100));
}
}
}
i have a bitmap captured from the camera. i can place a transparent circle on the bitmap. what i'd like to do is make the circle's pixels a new separate bitmap that is circular in shape. i have an algorithm in place that targets the circle's pixels but how can i copy these pixels into another bitmap that is circular in shape and has the circl's size?
public void findCirclePixels(){
for (int i=centreX-50; i < centreX+50; ++i) {
for (int y=centreY-50; y <centreY+50 ; ++y) {
if( Math.sqrt( Math.pow(i - centreX, 2) + ( Math.pow(y - centreY, 2) ) ) <= radius ){
bgr.setPixel(i,y,Color.rgb(Progress+50,Progress,Progress+100));
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法制作圆形位图。您可以实现的最接近的是方形位图,其像素的圆形核心(alpha=255)和封闭周长(alpha=0)。这样,当您合成它时,它将充当一个圆。
You cannot make circular bitmaps. The closest you can achieve is a square bitmap with a circular core of pixels with alpha=255 and an enclosing perimeter with alpha=0. That way, it will act as a circle when you composite it.