如何从原始位图的一部分制作新的圆形位图?

发布于 2024-11-13 05:58:03 字数 523 浏览 7 评论 0原文

我有一张从相机捕获的位图。我可以在位图上放置一个透明圆圈。我想做的是将圆圈的像素制作成一个新的单独的圆形位图。我有一个针对圆圈像素的算法,但如何将这些像​​素复制到另一个形状为圆形且具有圆圈大小的位图中?

    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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潜移默化 2024-11-20 05:58:03

您无法制作圆形位图。您可以实现的最接近的是方形位图,其像素的圆形核心(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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文