如何使通过jxImageview显示的图像的背景色透明
我制作了一个 JxImageView 对象并为其设置了一个图像,现在我得到了白色作为其背景,这不在原始图像中。我只想从视口中删除白色。
I made a JxImageView object and set an image to it, now i got white color as its background which is not in the original image. i just want to remove the white color from the viewport.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
阅读 后docs,我得出结论(如果我错了,请纠正我)你无法更改白色背景
在 JxImageView 的构造函数中,你会看到:
并且 checkerPaint 无法访问
After reading the docs, I conclude (correct me if I am wrong) you can't change the white background
In the Constructor of JxImageView, you see:
and checkerPaint cannot be accessed
我不知道 JxImageView,但我不知道它如何改变图像的背景颜色,因为图像没有任何背景颜色。这可能只是意味着图像的某些部分是透明的,并且您看到的白色是显示图像的组件的背景颜色:
JxImageView
。您应该将 JxImageView 的背景颜色更改为适合您的颜色。JxImageView 本身也可以是透明的,在这种情况下,您将看到其父组件的背景。
尝试在图像编辑器中加载图像以确认图像是透明的。
I don't know JxImageView, but I don't see how it could change the background color of an image, because an image doesn't have any background color. It probably just means that some parts of the image are transparent, and that the white color you see is the background color of the component which displays the image:
JxImageView
. You should just probably change the background color of theJxImageView
, to the color that suits you.The JxImageView could also itself be transparent, in which case you would see its parent component's background.
Try loading the image in an image editor to confirm that the image is transparent.
JXImageView bug 已在当前快照中修复(顺便说一句,SwingX 1.6.3 之后,就在如果您错过了 发布公告 : )要替换默认的方格背景,只需设置一个自定义背景画家:
JXImageView bug fixed in the current snapshot (btw, post-SwingX 1.6.3, just in case you missed the release announcement :) To replace the default checkered background, simply set a custom background painter: