我需要将图像缩放到小图像并将图像存储到黑莓设备中(作为小图像)?
答案 0 :(得分:3)
缩放图像就足够简单了。
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);
}
这将返回图像的副本,根据您需要的宽度和高度进行缩放。
答案 1 :(得分:0)