Search in sources :

Example 1 with ImageDecodingInfo

use of com.nostra13.universalimageloader.core.decode.ImageDecodingInfo in project Android-Universal-Image-Loader by nostra13.

the class BaseImageDecoder method prepareDecodingOptions.

protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    int scale;
    if (scaleType == ImageScaleType.NONE) {
        scale = 1;
    } else if (scaleType == ImageScaleType.NONE_SAFE) {
        scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
    } else {
        ImageSize targetSize = decodingInfo.getTargetSize();
        boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2;
        scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
    }
    if (scale > 1 && loggingEnabled) {
        L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
    }
    Options decodingOptions = decodingInfo.getDecodingOptions();
    decodingOptions.inSampleSize = scale;
    return decodingOptions;
}
Also used : ImageScaleType(com.nostra13.universalimageloader.core.assist.ImageScaleType) Options(android.graphics.BitmapFactory.Options) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize)

Example 2 with ImageDecodingInfo

use of com.nostra13.universalimageloader.core.decode.ImageDecodingInfo in project Android-Universal-Image-Loader by nostra13.

the class LoadAndDisplayImageTask method resizeAndSaveImage.

/**
 * Decodes image file into Bitmap, resize it and save it back
 */
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
    // Decode image file, compress and re-save it
    boolean saved = false;
    File targetFile = configuration.diskCache.get(uri);
    if (targetFile != null && targetFile.exists()) {
        ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight);
        DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options).imageScaleType(ImageScaleType.IN_SAMPLE_INT).build();
        ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE, getDownloader(), specialOptions);
        Bitmap bmp = decoder.decode(decodingInfo);
        if (bmp != null && configuration.processorForDiskCache != null) {
            L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey);
            bmp = configuration.processorForDiskCache.process(bmp);
            if (bmp == null) {
                L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey);
            }
        }
        if (bmp != null) {
            saved = configuration.diskCache.save(uri, bmp);
            bmp.recycle();
        }
    }
    return saved;
}
Also used : Bitmap(android.graphics.Bitmap) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize) ImageDecodingInfo(com.nostra13.universalimageloader.core.decode.ImageDecodingInfo) File(java.io.File)

Example 3 with ImageDecodingInfo

use of com.nostra13.universalimageloader.core.decode.ImageDecodingInfo in project LibreraReader by foobnix.

the class LoadAndDisplayImageTask method decodeImage.

private Bitmap decodeImage(String imageUri) throws IOException {
    ViewScaleType viewScaleType = imageAware.getScaleType();
    ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType, getDownloader(), options);
    return decoder.decode(decodingInfo);
}
Also used : ImageDecodingInfo(com.nostra13.universalimageloader.core.decode.ImageDecodingInfo) ViewScaleType(com.nostra13.universalimageloader.core.assist.ViewScaleType)

Example 4 with ImageDecodingInfo

use of com.nostra13.universalimageloader.core.decode.ImageDecodingInfo in project Android-Universal-Image-Loader by nostra13.

the class LoadAndDisplayImageTask method decodeImage.

private Bitmap decodeImage(String imageUri) throws IOException {
    ViewScaleType viewScaleType = imageAware.getScaleType();
    ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType, getDownloader(), options);
    return decoder.decode(decodingInfo);
}
Also used : ImageDecodingInfo(com.nostra13.universalimageloader.core.decode.ImageDecodingInfo) ViewScaleType(com.nostra13.universalimageloader.core.assist.ViewScaleType)

Example 5 with ImageDecodingInfo

use of com.nostra13.universalimageloader.core.decode.ImageDecodingInfo in project Android-Universal-Image-Loader by nostra13.

the class BaseImageDecoder method defineImageSizeAndRotation.

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);
}
Also used : Options(android.graphics.BitmapFactory.Options) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize)

Aggregations

ImageSize (com.nostra13.universalimageloader.core.assist.ImageSize)8 Bitmap (android.graphics.Bitmap)4 Options (android.graphics.BitmapFactory.Options)4 ImageScaleType (com.nostra13.universalimageloader.core.assist.ImageScaleType)4 ImageDecodingInfo (com.nostra13.universalimageloader.core.decode.ImageDecodingInfo)4 Matrix (android.graphics.Matrix)2 ViewScaleType (com.nostra13.universalimageloader.core.assist.ViewScaleType)2 File (java.io.File)2 InputStreamBitmap (com.foobnix.sys.InputStreamBitmap)1