无缓冲图像的字母混合
我想在 Graphics2D 上绘制一个形状,如果它与某个范围相交,则将其一部分着色为不同的颜色。我通过使用 AlphaComposite 和 AlphaComposite.SRC_IN 将 2 个形状绘制到 BufferedImage(原始形状和将导致颜色变化的区域)中来实现此目的。问题是,如果滚动画布,屏幕就会变得滞后,因为每次调用 Paint 方法时都会创建一个缓冲图像。
有没有办法在不使用缓冲图像对象的情况下实现相同的效果(两个形状重叠,只有第二个形状的重叠区域是彩色的)?
干杯, 最大限度
I'd like to draw a shape on a Graphics2D and colour a part of it different if it intersects a certain range. I managed to do this by drawing 2 shapes into a BufferedImage (the original shape and the area that will cause a change of colour) by using AlphaComposite and AlphaComposite.SRC_IN. The problem is that if the canvas is scrolled, the screen becomes laggy as every time the paint method is called, a buffered image is created.
Is there any way of achieving the same effect (2 shapes overlapping, only 2nd shape's overlap area is coloured) without using a buffered image object?
Cheers,
Max
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否完全理解您想要做什么,但您不应该在每次调用绘制方法时创建缓冲图像;仅当要显示的对象发生更改时。
I'm not sure I undertand fully what you're trying to do, but you shouldn't create the buffered image each time the paint method is called; only when something is changed in the objects to display.