如何在 Java ME 中减少图像颜色深度/压缩图像大小?
我需要将手机上的图像传输到服务器。 我可以减小图像屏幕尺寸,但不能减小内存大小。 我知道我必须处理颜色深度。 J2ME 似乎没有提供 J2SE 中可用的任何缩放方法:
image rescaled = image.getScaledInstance(thumbWidth, thumbHeight, Image.SCALE_AREA_AVERAGING);
BufferedImage biRescaled = toBufferedImage(rescaled, thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB);
我将如何解决这个问题? 我想在传输到服务器之前减少图像内存大小。
I need to transmit the image from the mobile phone to the server. I am able to reduce the image screen size but not the memory size. I understand i have to deal with the color depth.
J2ME does not seem to offer any scaling method which is available in J2SE:
image rescaled = image.getScaledInstance(thumbWidth, thumbHeight, Image.SCALE_AREA_AVERAGING);
BufferedImage biRescaled = toBufferedImage(rescaled, thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB);
How I would I tackle this ? I would like to reduce the image memory size before i transmit to the server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下这个 (GEAR Java 移动框架)。 有一个实用程序包,其中包含一个名为 ImageHelper 的类。 它包含一些缩放图像从而减小其尺寸的方法。 它在移动设备上运行良好,并且执行速度相当快。 如果您的图像仍然很大或者您不想丢失太多数据,请考虑使用压缩算法。 zlib 提供了一个非常好的解决方案,并且有一个可供使用的 J2ME 实现。
Take a look to this (GEAR Java Mobile Framework). There is an utility package with a class named ImageHelper. It contains some methods to scale an image and thus reduce it's size. It works good on mobile devices and it's reasonably fast to execute. If your image is still a big one or you don't want to loose too much data, consider using a compression algorithm. zlib offers a very good solution and there's an implementation for J2ME ready to be used.