Search in sources :

Example 1 with ImageDecodingInfo

use of com.smartandroid.sa.zUImageLoader.core.decode.ImageDecodingInfo in project SmartAndroidSource by jaychou2012.

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.smartandroid.sa.zUImageLoader.core.assist.ImageSize) ImageDecodingInfo(com.smartandroid.sa.zUImageLoader.core.decode.ImageDecodingInfo) File(java.io.File)

Example 2 with ImageDecodingInfo

use of com.smartandroid.sa.zUImageLoader.core.decode.ImageDecodingInfo in project SmartAndroidSource by jaychou2012.

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.smartandroid.sa.zUImageLoader.core.decode.ImageDecodingInfo) ViewScaleType(com.smartandroid.sa.zUImageLoader.core.assist.ViewScaleType)

Aggregations

ImageDecodingInfo (com.smartandroid.sa.zUImageLoader.core.decode.ImageDecodingInfo)2 Bitmap (android.graphics.Bitmap)1 ImageSize (com.smartandroid.sa.zUImageLoader.core.assist.ImageSize)1 ViewScaleType (com.smartandroid.sa.zUImageLoader.core.assist.ViewScaleType)1 File (java.io.File)1