如何使通过jxImageview显示的图像的背景色透明

发布于 2024-12-27 03:49:15 字数 74 浏览 0 评论 0原文

我制作了一个 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 技术交流群。

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

发布评论

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

评论(3

写给空气的情书 2025-01-03 03:49:15

阅读 后docs,我得出结论(如果我错了,请纠正我)你无法更改白色背景

在 JxImageView 的构造函数中,你会看到:

/** Creates a new instance of JXImageView */
public JXImageView() {
      checkerPaint = ColorUtil.getCheckerPaint(Color.white,
      new Color(250, 250, 250), 50);
      setEditable(true);
}

并且 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:

/** Creates a new instance of JXImageView */
public JXImageView() {
      checkerPaint = ColorUtil.getCheckerPaint(Color.white,
      new Color(250, 250, 250), 50);
      setEditable(true);
}

and checkerPaint cannot be accessed

巷子口的你 2025-01-03 03:49:15

我不知道 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 the JxImageView, 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.

杀手六號 2025-01-03 03:49:15

JXImageView bug 已在当前快照中修复(顺便说一句,SwingX 1.6.3 之后,就在如果您错过了 发布公告 : )要替换默认的方格背景,只需设置一个自定义背景画家:

JXImageView ipa = new JXImageView();
ipa.setBackgroundPainter(new MattePainter(Color.RED));

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:

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