我使用下面的代码来调整黑莓图像的大小,但这会导致图像质量不佳。请同样告知。
{
JPEGEncodedImage encoder = null;
encode_image = sizeImage(encode_image, (int)newWidth,(int)newHeight);
encoder=JPEGEncodedImage.encode(encode_image.getBitmap(),100);
}
public EncodedImage sizeImage(EncodedImage image, int width,
int height) {
EncodedImage result = null;
int currentWidthFixed32 = Fixed32.toFP(image.getWidth());
int currentHeightFixed32 = Fixed32.toFP(image.getHeight());
int requiredWidthFixed32 = Fixed32.toFP(width);
int requiredHeightFixed32 = Fixed32.toFP(height);
int scaleXFixed32 = Fixed32.div(currentWidthFixed32,
requiredWidthFixed32);
int scaleYFixed32 = Fixed32.div(currentHeightFixed32,
requiredHeightFixed32);
result = image.scaleImage32(scaleXFixed32, scaleYFixed32);
return result;
}
答案 0 :(得分:1)
BlackBerry完成的默认图像缩放非常原始,通常看起来不太好。如果您使用5.0进行构建,则使用双线性或Lanczos等过滤器可以new API进行更好的图像缩放。
答案 1 :(得分:0)
您可能已经解决了问题,但对于需要编写与旧版API兼容的代码的其他编码人员,您也可以使用此帖子中的代码:Strange out of memory issue while loading an image to a Bitmap object
线程是关于android的,但图像缩放数学和逻辑是相同的:)