对于离屏渲染来说,最有用的 java.awt.image.BufferedImage 类型是什么?
我正在创建一个缓冲图像,该图像将成为 JComponent 的快照(通过 Paint())并在 ImageIcon。 BufferedImage(int width, int height, int imageType)
构造函数,但是我应该使用哪一个呢?
我确信它们中的任何一个都可以工作,但是哪些比其他更好呢? 我该如何选择呢? 为什么?
I am creating a buffered image that is going to be a snapshot of a JComponent (via paint()) and rendered inside an ImageIcon. There are a large amount of types in the BufferedImage(int width, int height, int imageType)
constructor, but which one should I use?
I am sure that any of them would work, but which ones are better than the others? How should I pick one? And Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参见 GraphicsConfiguration。 createCompatibleImage(int, int) 用于帮助程序在许多可用类型中创建“良好”类型的 BufferedImage。
如何获得 GraphicsConfiguration 实例来进行此调用? 这取决于您的代码在哪里执行。 请参阅许多方法 通过 getGraphicsConfiguration() 或 getDeviceConfiguration() 等方法获取 GraphicsConfiguration。
See GraphicsConfiguration.createCompatibleImage(int, int) for a helper to create a BufferedImage of a "good" type among the many available types.
How to get your hands on a GraphicsConfiguration instance to make this call? It depends on where your code is executing. See the many methods for getting your hands on a GraphicsConfiguration via methods like getGraphicsConfiguration() or getDeviceConfiguration().