当我绘制大尺寸图像时,java中的原因是什么,导致速度缓慢?
当我尝试绘制尺寸为 1280*768 的图像时,我遇到了缓慢的问题,它的格式是 PNG,它的大小几乎是 3.26 MB,但是当我将它转换为 JPEG 时,它的大小是 226KB,!慢速问题消失了! ,
我的问题是为什么在尝试绘制大尺寸的缓冲图像时会出现缓慢? java是只处理小尺寸的图像还是什么?
i had problem with slow when i tried to draw an image with scale : 1280*768 and it's format is PNG and it's size is 3.26 MB nearly , but when i converted it to JPEG , it's size be 226KB , ! and the slownes problem disappeared !! ,
my question is why slowness occured while trying to draw an buffered image with large size ? is java handle small size of images only or what ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将图像缩小为 JPEG 时,会丢失一些图像数据,从而使文件变短。
读取较短的文件所需的时间较少。
并且
3.26 MB > 226 KB!
您可能在屏幕上看不到任何差异,因为原始文件太大,可能无法显示每个像素,但转换为 JPEG 时质量会有所损失。
查看此网站有关图像文件格式的信息:GIF、PNG、或者 JPEG 的?
编辑 您还可以查看此网站上的图像绘制:http://www.kitfox.com/javaOne2007/javaOne-notes.pdf
您可以使用 java.awt.RenderingHints. 将其与 BufferedImageOp 一起使用可以使图像加载速度更快(但会牺牲一些质量)。
我希望这有帮助!
When you shrink an image to JPEG, you lose some of the image data, making the file shorter.
It takes less time to read a shorter file.
And
3.26 MB > 226 KB
!You might not see a difference on your screen because the original file is so large, that not every pixel might be shown, but there is a loss of quality when converting to JPEG.
Check out this site about image file formats: GIF's, PNG's, or JPEG's?
EDIT You can also look at this website on image drawing: http://www.kitfox.com/javaOne2007/javaOne-notes.pdf
You can render images quickly using java.awt.RenderingHints. Using this with BufferedImageOp can make your images load faster (at the expense of some quality, though).
I hope this helped!