如何确定位图的透明度颜色

发布于 2024-08-27 13:18:55 字数 218 浏览 4 评论 0原文

我知道您可以以编程方式确定.gif 的透明度颜色

有没有办法对位图执行相同的操作?

现在,我通过在外边缘周围采样来试探性地执行此操作,但这当然不是 100% 可靠。

I know you can programmatically determine the tranparency color of a .gif

Is there a way to do the same for a Bitmap?

Right now, I am doing this heuristically by sampling around the outer edge but of course this is not 100% reliable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

相守太难 2024-09-03 13:18:55

我不认为 BMP 文件格式支持透明度的概念。我的理解是,如果 BMP 图像与透明度一起使用,则它使用应用程序定义的颜色,例如 RGB(255,0,255) 来指定透明区域。

I don't believe the BMP file format supports the concept of transparency. My understanding is that if BMP images are used with transparency, it's using an application-defined colour, like RGB(255,0,255) to specify transparent areas.

楠木可依 2024-09-03 13:18:55

您可以做的是:

  • 对被遮挡的图像进行采样。
  • 应用精明的边缘检测算法来检测位图图像中对象的外边缘。
  • 您可以是近似的,您可能还需要进行一些调整才能仅获得外边缘。
  • 然后,您可以执行这 2 个样本的交集,以跨位图图像边缘获取被遮挡的图像。
  • 现在,您将拥有 2 张图像。确保遮挡提取的图像是透明的并且位于顶部。
  • 只需将原始位图放在提取的图像下方,您的位图图像也将实现透明! :)

What you may do is:

  • To sample the occluded image.
  • Apply canny edge detection algorithm to detect outer edges of the object in your bitmap image.
  • You can be approximate, you may also need to tweak a bit to get only the outer edges.
  • Then you can perform an intersection of these 2 samples to get the occluded image, across the bitmap image edges.
  • By now, you will be having 2 images. Make sure the occlusion-extracted image is transparent and on top.
  • Just put the original bitmap beneath the extracted image and you'll achieve transparency with your bitmap image too! :)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文