2
我需要将图像缩放为小图像并将该图像存储到黑莓设备中(作为小图像)?黑莓手机 - 如何调整大小和存储图像?
我需要将图像缩放为小图像并将该图像存储到黑莓设备中(作为小图像)?黑莓手机 - 如何调整大小和存储图像?
如果图像打包,甚至通过网络或文件系统采集图像,则缩放图像就足够直接了。
public EncodedImage scaleImage(EncodedImage source, int requiredWidth, int requiredHeight) {
int currentWidthFixed32 = Fixed32.toFP(source.getWidth());
int requiredWidthFixed32 = Fixed32.toFP(requiredWidth);
int scaleXFixed32 = Fixed32.div(currentWidthFixed32, requiredWidthFixed32);
int currentHeightFixed32 = Fixed32.toFP(source.getHeight());
int requiredHeightFixed32 = Fixed32.toFP(requiredHeight);
int scaleYFixed32 = Fixed32.div(currentHeightFixed32, requiredHeightFixed32);
return source.scaleImage32(scaleXFixed32, scaleYFixed32);
}
这会返回图像的副本,根据您需要的宽度和高度进行缩放。
它保存在设备上,你必须选择:文件系统或persistentStorage? – bryanallott 2010-05-18 14:32:21
尝试各种不同的东西:很多来自这个网站 - 没有工作,直到我尝试你的解决方案。谢谢。 – BonanzaDriver 2011-09-30 03:45:48