inScaled = false is ignored
I want load bitmap without any scaling but inScaled is ignored.
BitmapFactory.Options options = new BitmapFactory.Options();
// for quick memory release
options.inPurgeable = true;
options.inInputShareable = true;
//don't scale
**options.inScaled = false;**
options.inDensity = 0;
options.inTargetDensity = 0;
options.inSampleSize =1;
options.inScreenDensity = 0;
// ...
DisplayImageOptions.Builder b = new DisplayImageOptions.Builder();
**b.imageScaleType(ImageScaleType.NONE);**
b.decodingOptions(options);
b.cacheInMemory(false);
b.cacheOnDisc(true);
b.showImageForEmptyUri(R.drawable.publication_page_full);
b.showImageOnFail(R.drawable.publication_page_full);
// ...
imgOptions = b.build();
I also try:
ImageSize targetSize = new ImageSize(120, 80); // result Bitmap will be fit to this size
imageLoader.loadImage(imageUri, targetSize, displayOptions, listner);
but i dosn't work:/
Anybody solve this?
decodingOptions are considered by Android-Universal-Image-Loader?
I faoud that new Options are created and this why ImageSize is wrong. BaseImage Decoder:
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo)
throws IOException {
Options options = new Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(imageStream, null, options);
ExifInfo exif;
String imageUri = decodingInfo.getImageUri();
if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) {
exif = defineExifOrientation(imageUri);
} else {
exif = new ExifInfo();
}
return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif);
}
and you use this image size i decode mathod (line 77) sometime returned size is -1,-1 and after calculate scale is 0. This causes decode error.
My fix:
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo)
throws IOException {
Options options = new Options();
options.inJustDecodeBounds = true;
//clone
Options userOptions = decodingInfo.getDecodingOptions();
if(userOptions!= null){
options.inDensity = userOptions.inDensity;
options.inDither = userOptions.inDither;
options.inInputShareable = userOptions.inInputShareable;
options.inPurgeable = userOptions.inPurgeable;
options.inScaled = userOptions.inScaled;
options.inScreenDensity = userOptions.inScreenDensity;
options.inTargetDensity = userOptions.inTargetDensity;
}
BitmapFactory.decodeStream(imageStream, null, options);
ExifInfo exif;
String imageUri = decodingInfo.getImageUri();
if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) {
exif = defineExifOrientation(imageUri);
} else {
exif = new ExifInfo();
}
return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif);
}
If you read Java docs of DisplayImageOptions.decodingOptions(...) method then you can see answer for your question. Your fix should work for you.
Yes, i have read.
- NOTE: {@link Options#inSampleSize} of incoming options will NOT be considered. Library
- calculate the most appropriate sample size itself according yo {@link #imageScaleType(ImageScaleType)}
- options.
but what about inScaled = false? I think that some option to turn off auto scaling is needed. Thank you for answer. Great and useful lib!
I'm not sure how inScaled option works, its documentation isn't clear for me.