Java 类com.nostra13.universalimageloader.core.assist.ImageSize 实例源码

项目:GitHub    文件:ImageDecodingInfo.java   
public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType,
                         ImageDownloader downloader, DisplayImageOptions displayOptions) {
    this.imageKey = imageKey;
    this.imageUri = imageUri;
    this.originalImageUri = originalImageUri;
    this.targetSize = targetSize;

    this.imageScaleType = displayOptions.getImageScaleType();
    this.viewScaleType = viewScaleType;

    this.downloader = downloader;
    this.extraForDownloader = displayOptions.getExtraForDownloader();

    considerExifParams = displayOptions.isConsiderExifParams();
    decodingOptions = new Options();
    copyOptions(displayOptions.getDecodingOptions(), decodingOptions);
}
项目:GitHub    文件:BaseImageDecoder.java   
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;
}
项目:ImageLoaderSupportGif    文件:BaseImageDecoder.java   
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;
}
项目:letv    文件:ImageSizeUtils.java   
public static float computeImageScale(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType, boolean stretch) {
    int destWidth;
    int srcWidth = srcSize.getWidth();
    int srcHeight = srcSize.getHeight();
    int targetWidth = targetSize.getWidth();
    int targetHeight = targetSize.getHeight();
    float widthScale = ((float) srcWidth) / ((float) targetWidth);
    float heightScale = ((float) srcHeight) / ((float) targetHeight);
    int destHeight;
    if ((viewScaleType != ViewScaleType.FIT_INSIDE || widthScale < heightScale) && (viewScaleType != ViewScaleType.CROP || widthScale >= heightScale)) {
        destWidth = (int) (((float) srcWidth) / heightScale);
        destHeight = targetHeight;
    } else {
        destWidth = targetWidth;
        destHeight = (int) (((float) srcHeight) / widthScale);
    }
    if ((stretch || destWidth >= srcWidth || destHeight >= srcHeight) && (!stretch || destWidth == srcWidth || destHeight == srcHeight)) {
        return 1.0f;
    }
    return ((float) destWidth) / ((float) srcWidth);
}
项目:letv    文件:LoadAndDisplayImageTask.java   
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
    File targetFile = this.configuration.diskCache.get(this.uri);
    if (targetFile == null || !targetFile.exists()) {
        return false;
    }
    Bitmap bmp = this.decoder.decode(new ImageDecodingInfo(this.memoryCacheKey, Scheme.FILE.wrap(targetFile.getAbsolutePath()), this.uri, new ImageSize(maxWidth, maxHeight), ViewScaleType.FIT_INSIDE, getDownloader(), new Builder().cloneFrom(this.options).imageScaleType(ImageScaleType.IN_SAMPLE_INT).build()));
    if (!(bmp == null || this.configuration.processorForDiskCache == null)) {
        L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, this.memoryCacheKey);
        bmp = this.configuration.processorForDiskCache.process(bmp);
        if (bmp == null) {
            L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, this.memoryCacheKey);
        }
    }
    if (bmp == null) {
        return false;
    }
    boolean saved = this.configuration.diskCache.save(this.uri, bmp);
    bmp.recycle();
    return saved;
}
项目:letv    文件:BaseImageDecoder.java   
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
    int scale;
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.NONE) {
        scale = 1;
    } else if (scaleType == ImageScaleType.NONE_SAFE) {
        scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
    } else {
        boolean powerOf2;
        ImageSize targetSize = decodingInfo.getTargetSize();
        if (scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2) {
            powerOf2 = true;
        } else {
            powerOf2 = false;
        }
        scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
    }
    if (scale > 1 && this.loggingEnabled) {
        L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), Integer.valueOf(scale), decodingInfo.getImageKey());
    }
    Options decodingOptions = decodingInfo.getDecodingOptions();
    decodingOptions.inSampleSize = scale;
    return decodingOptions;
}
项目:GifImageLoader    文件:ImageDecodingInfo.java   
public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType,
                         ImageDownloader downloader, DisplayImageOptions displayOptions) {
    this.imageKey = imageKey;
    this.imageUri = imageUri;
    this.originalImageUri = originalImageUri;
    this.targetSize = targetSize;

    this.imageScaleType = displayOptions.getImageScaleType();
    this.viewScaleType = viewScaleType;

    this.downloader = downloader;
    this.extraForDownloader = displayOptions.getExtraForDownloader();

    considerExifParams = displayOptions.isConsiderExifParams();
    decodingOptions = new Options();
    copyOptions(displayOptions.getDecodingOptions(), decodingOptions);
}
项目:boohee_v5.6    文件:ImageSizeUtils.java   
public static float computeImageScale(ImageSize srcSize, ImageSize targetSize, ViewScaleType
        viewScaleType, boolean stretch) {
    int destWidth;
    int srcWidth = srcSize.getWidth();
    int srcHeight = srcSize.getHeight();
    int targetWidth = targetSize.getWidth();
    int targetHeight = targetSize.getHeight();
    float widthScale = ((float) srcWidth) / ((float) targetWidth);
    float heightScale = ((float) srcHeight) / ((float) targetHeight);
    int destHeight;
    if ((viewScaleType != ViewScaleType.FIT_INSIDE || widthScale < heightScale) &&
            (viewScaleType != ViewScaleType.CROP || widthScale >= heightScale)) {
        destWidth = (int) (((float) srcWidth) / heightScale);
        destHeight = targetHeight;
    } else {
        destWidth = targetWidth;
        destHeight = (int) (((float) srcHeight) / widthScale);
    }
    if ((stretch || destWidth >= srcWidth || destHeight >= srcHeight) && (!stretch ||
            destWidth == srcWidth || destHeight == srcHeight)) {
        return 1.0f;
    }
    return ((float) destWidth) / ((float) srcWidth);
}
项目:boohee_v5.6    文件:BaseImageDecoder.java   
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo
        decodingInfo) throws IOException {
    ExifInfo exif;
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeStream(imageStream, null, options);
    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);
}
项目:boohee_v5.6    文件:BaseImageDecoder.java   
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
    int scale;
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.NONE) {
        scale = 1;
    } else if (scaleType == ImageScaleType.NONE_SAFE) {
        scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
    } else {
        boolean powerOf2;
        ImageSize targetSize = decodingInfo.getTargetSize();
        if (scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2) {
            powerOf2 = true;
        } else {
            powerOf2 = false;
        }
        scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo
                .getViewScaleType(), powerOf2);
    }
    if (scale > 1 && this.loggingEnabled) {
        L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), Integer.valueOf
                (scale), decodingInfo.getImageKey());
    }
    Options decodingOptions = decodingInfo.getDecodingOptions();
    decodingOptions.inSampleSize = scale;
    return decodingOptions;
}
项目:wallpaperboard    文件:WallpaperHelper.java   
public static ImageSize getTargetSize(@NonNull Context context) {
    Point point = WindowHelper.getScreenSize(context);
    int targetHeight = point.y;
    int targetWidth = point.x;

    if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        targetHeight = point.x;
        targetWidth = point.y;
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        int statusBarHeight = WindowHelper.getStatusBarHeight(context);
        int navBarHeight = WindowHelper.getNavigationBarHeight(context);
        targetHeight += (statusBarHeight + navBarHeight);
    }
    return new ImageSize(targetWidth, targetHeight);
}
项目:GitHub    文件:ImageSizeUtils.java   
/**
 * Computes minimal sample size for downscaling image so result image size won't exceed max acceptable OpenGL
 * texture size.<br />
 * We can't create Bitmap in memory with size exceed max texture size (usually this is 2048x2048) so this method
 * calculate minimal sample size which should be applied to image to fit into these limits.
 *
 * @param srcSize Original image size
 * @return Minimal sample size
 */
public static int computeMinImageSampleSize(ImageSize srcSize) {
    final int srcWidth = srcSize.getWidth();
    final int srcHeight = srcSize.getHeight();
    final int targetWidth = maxBitmapSize.getWidth();
    final int targetHeight = maxBitmapSize.getHeight();

    final int widthScale = (int) Math.ceil((float) srcWidth / targetWidth);
    final int heightScale = (int) Math.ceil((float) srcHeight / targetHeight);

    return Math.max(widthScale, heightScale); // max
}
项目:GitHub    文件:ImageSizeUtils.java   
/**
 * Computes scale of target size (<b>targetSize</b>) to source size (<b>srcSize</b>).<br />
 * <br />
 * <b>Examples:</b><br />
 * <p/>
 * <pre>
 * srcSize(40x40), targetSize(10x10) -> scale = 0.25
 *
 * srcSize(10x10), targetSize(20x20), stretch = false -> scale = 1
 * srcSize(10x10), targetSize(20x20), stretch = true  -> scale = 2
 *
 * srcSize(100x100), targetSize(20x40), viewScaleType = FIT_INSIDE -> scale = 0.2
 * srcSize(100x100), targetSize(20x40), viewScaleType = CROP       -> scale = 0.4
 * </pre>
 *
 * @param srcSize       Source (image) size
 * @param targetSize    Target (view) size
 * @param viewScaleType {@linkplain ViewScaleType Scale type} for placing image in view
 * @param stretch       Whether source size should be stretched if target size is larger than source size. If <b>false</b>
 *                      then result scale value can't be greater than 1.
 * @return Computed scale
 */
public static float computeImageScale(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType,
        boolean stretch) {
    final int srcWidth = srcSize.getWidth();
    final int srcHeight = srcSize.getHeight();
    final int targetWidth = targetSize.getWidth();
    final int targetHeight = targetSize.getHeight();

    final float widthScale = (float) srcWidth / targetWidth;
    final float heightScale = (float) srcHeight / targetHeight;

    final int destWidth;
    final int destHeight;
    if ((viewScaleType == ViewScaleType.FIT_INSIDE && widthScale >= heightScale) || (viewScaleType == ViewScaleType.CROP && widthScale < heightScale)) {
        destWidth = targetWidth;
        destHeight = (int) (srcHeight / widthScale);
    } else {
        destWidth = (int) (srcWidth / heightScale);
        destHeight = targetHeight;
    }

    float scale = 1;
    if ((!stretch && destWidth < srcWidth && destHeight < srcHeight) || (stretch && destWidth != srcWidth && destHeight != srcHeight)) {
        scale = (float) destWidth / srcWidth;
    }

    return scale;
}
项目:GitHub    文件:ImageLoaderConfiguration.java   
ImageSize getMaxImageSize() {
    DisplayMetrics displayMetrics = resources.getDisplayMetrics();

    int width = maxImageWidthForMemoryCache;
    if (width <= 0) {
        width = displayMetrics.widthPixels;
    }
    int height = maxImageHeightForMemoryCache;
    if (height <= 0) {
        height = displayMetrics.heightPixels;
    }
    return new ImageSize(width, height);
}
项目:GitHub    文件:LoadAndDisplayImageTask.java   
/** 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;
}
项目:GitHub    文件:BaseImageDecoder.java   
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);
}
项目:GitHub    文件:BaseImageDecoder.java   
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo,
        int rotation, boolean flipHorizontal) {
    Matrix m = new Matrix();
    // Scale to exact size if need
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
        ImageSize srcSize = new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation);
        float scale = ImageSizeUtils.computeImageScale(srcSize, decodingInfo.getTargetSize(), decodingInfo
                .getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED);
        if (Float.compare(scale, 1f) != 0) {
            m.setScale(scale, scale);

            if (loggingEnabled) {
                L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), scale, decodingInfo.getImageKey());
            }
        }
    }
    // Flip bitmap if need
    if (flipHorizontal) {
        m.postScale(-1, 1);

        if (loggingEnabled) L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
    }
    // Rotate bitmap if need
    if (rotation != 0) {
        m.postRotate(rotation);

        if (loggingEnabled) L.d(LOG_ROTATE_IMAGE, rotation, decodingInfo.getImageKey());
    }

    Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap
            .getHeight(), m, true);
    if (finalBitmap != subsampledBitmap) {
        subsampledBitmap.recycle();
    }
    return finalBitmap;
}
项目:ImageLoaderSupportGif    文件:LoadAndDisplayImageTask.java   
/**
 * 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;
}
项目:GitHub    文件:NonViewAware.java   
public NonViewAware(String imageUri, ImageSize imageSize, ViewScaleType scaleType) {
    if (imageSize == null) throw new IllegalArgumentException("imageSize must not be null");
    if (scaleType == null) throw new IllegalArgumentException("scaleType must not be null");

    this.imageUri = imageUri;
    this.imageSize = imageSize;
    this.scaleType = scaleType;
}
项目:GitHub    文件:ImageLoadingInfo.java   
public ImageLoadingInfo(String uri, ImageAware imageAware, ImageSize targetSize, String memoryCacheKey,
        DisplayImageOptions options, ImageLoadingListener listener,
        ImageLoadingProgressListener progressListener, ReentrantLock loadFromUriLock) {
    this.uri = uri;
    this.imageAware = imageAware;
    this.targetSize = targetSize;
    this.options = options;
    this.listener = listener;
    this.progressListener = progressListener;
    this.loadFromUriLock = loadFromUriLock;
    this.memoryCacheKey = memoryCacheKey;
}
项目:letv    文件:ImageSizeUtils.java   
public static ImageSize defineTargetSizeForView(ImageAware imageAware, ImageSize maxImageSize) {
    int width = imageAware.getWidth();
    if (width <= 0) {
        width = maxImageSize.getWidth();
    }
    int height = imageAware.getHeight();
    if (height <= 0) {
        height = maxImageSize.getHeight();
    }
    return new ImageSize(width, height);
}
项目:letv    文件:ImageSizeUtils.java   
public static int computeImageSampleSize(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType, boolean powerOf2Scale) {
    int srcWidth = srcSize.getWidth();
    int srcHeight = srcSize.getHeight();
    int targetWidth = targetSize.getWidth();
    int targetHeight = targetSize.getHeight();
    int scale = 1;
    int halfWidth;
    int halfHeight;
    switch (viewScaleType) {
        case FIT_INSIDE:
            if (!powerOf2Scale) {
                scale = Math.max(srcWidth / targetWidth, srcHeight / targetHeight);
                break;
            }
            halfWidth = srcWidth / 2;
            halfHeight = srcHeight / 2;
            while (true) {
                if (halfWidth / scale <= targetWidth && halfHeight / scale <= targetHeight) {
                    break;
                }
                scale *= 2;
            }
            break;
        case CROP:
            if (!powerOf2Scale) {
                scale = Math.min(srcWidth / targetWidth, srcHeight / targetHeight);
                break;
            }
            halfWidth = srcWidth / 2;
            halfHeight = srcHeight / 2;
            while (halfWidth / scale > targetWidth && halfHeight / scale > targetHeight) {
                scale *= 2;
            }
            break;
    }
    if (scale < 1) {
        scale = 1;
    }
    return considerMaxTextureSize(srcWidth, srcHeight, scale, powerOf2Scale);
}
项目:letv    文件:ImageLoaderConfiguration.java   
ImageSize getMaxImageSize() {
    DisplayMetrics displayMetrics = this.resources.getDisplayMetrics();
    int width = this.maxImageWidthForMemoryCache;
    if (width <= 0) {
        width = displayMetrics.widthPixels;
    }
    int height = this.maxImageHeightForMemoryCache;
    if (height <= 0) {
        height = displayMetrics.heightPixels;
    }
    return new ImageSize(width, height);
}
项目:letv    文件:ImageDecodingInfo.java   
public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType, ImageDownloader downloader, DisplayImageOptions displayOptions) {
    this.imageKey = imageKey;
    this.imageUri = imageUri;
    this.originalImageUri = originalImageUri;
    this.targetSize = targetSize;
    this.imageScaleType = displayOptions.getImageScaleType();
    this.viewScaleType = viewScaleType;
    this.downloader = downloader;
    this.extraForDownloader = displayOptions.getExtraForDownloader();
    this.considerExifParams = displayOptions.isConsiderExifParams();
    copyOptions(displayOptions.getDecodingOptions(), this.decodingOptions);
}
项目:letv    文件:BaseImageDecoder.java   
protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo) throws IOException {
    ExifInfo exif;
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeStream(imageStream, null, options);
    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);
}
项目:letv    文件:ImageLoader.java   
public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
    checkConfiguration();
    if (targetImageSize == null) {
        targetImageSize = this.configuration.getMaxImageSize();
    }
    if (options == null) {
        options = this.configuration.defaultDisplayImageOptions;
    }
    displayImage(uri, new NonViewAware(uri, targetImageSize, ViewScaleType.CROP), options, listener, progressListener);
}
项目:letv    文件:ImageLoader.java   
public Bitmap loadImageSync(String uri, ImageSize targetImageSize, DisplayImageOptions options) {
    if (options == null) {
        options = this.configuration.defaultDisplayImageOptions;
    }
    options = new Builder().cloneFrom(options).syncLoading(false).build();
    SyncImageLoadingListener listener = new SyncImageLoadingListener();
    loadImage(uri, targetImageSize, options, listener);
    return listener.getLoadedBitmap();
}
项目:ImageLoaderSupportGif    文件:BaseImageDecoder.java   
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);
}
项目:letv    文件:ImageLoadingInfo.java   
public ImageLoadingInfo(String uri, ImageAware imageAware, ImageSize targetSize, String memoryCacheKey, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener, ReentrantLock loadFromUriLock) {
    this.uri = uri;
    this.imageAware = imageAware;
    this.targetSize = targetSize;
    this.options = options;
    this.listener = listener;
    this.progressListener = progressListener;
    this.loadFromUriLock = loadFromUriLock;
    this.memoryCacheKey = memoryCacheKey;
}
项目:GifImageLoader    文件:ImageSizeUtils.java   
/**
 * Defines target size for image aware view. Size is defined by target
 * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware view} parameters, configuration
 * parameters or device display dimensions.<br />
 */
public static ImageSize defineTargetSizeForView(ImageAware imageAware, ImageSize maxImageSize) {
    int width = imageAware.getWidth();
    if (width <= 0) width = maxImageSize.getWidth();

    int height = imageAware.getHeight();
    if (height <= 0) height = maxImageSize.getHeight();

    return new ImageSize(width, height);
}
项目:GifImageLoader    文件:ImageSizeUtils.java   
/**
 * Computes minimal sample size for downscaling image so result image size won't exceed max acceptable OpenGL
 * texture size.<br />
 * We can't create Bitmap in memory with size exceed max texture size (usually this is 2048x2048) so this method
 * calculate minimal sample size which should be applied to image to fit into these limits.
 *
 * @param srcSize Original image size
 * @return Minimal sample size
 */
public static int computeMinImageSampleSize(ImageSize srcSize) {
    final int srcWidth = srcSize.getWidth();
    final int srcHeight = srcSize.getHeight();
    final int targetWidth = maxBitmapSize.getWidth();
    final int targetHeight = maxBitmapSize.getHeight();

    final int widthScale = (int) Math.ceil((float) srcWidth / targetWidth);
    final int heightScale = (int) Math.ceil((float) srcHeight / targetHeight);

    return Math.max(widthScale, heightScale); // max
}
项目:GifImageLoader    文件:ImageSizeUtils.java   
/**
 * Computes scale of target size (<b>targetSize</b>) to source size (<b>srcSize</b>).<br />
 * <br />
 * <b>Examples:</b><br />
 * <p/>
 * <pre>
 * srcSize(40x40), targetSize(10x10) -> scale = 0.25
 *
 * srcSize(10x10), targetSize(20x20), stretch = false -> scale = 1
 * srcSize(10x10), targetSize(20x20), stretch = true  -> scale = 2
 *
 * srcSize(100x100), targetSize(20x40), viewScaleType = FIT_INSIDE -> scale = 0.2
 * srcSize(100x100), targetSize(20x40), viewScaleType = CROP       -> scale = 0.4
 * </pre>
 *
 * @param srcSize       Source (image) size
 * @param targetSize    Target (view) size
 * @param viewScaleType {@linkplain ViewScaleType Scale type} for placing image in view
 * @param stretch       Whether source size should be stretched if target size is larger than source size. If <b>false</b>
 *                      then result scale value can't be greater than 1.
 * @return Computed scale
 */
public static float computeImageScale(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType,
        boolean stretch) {
    final int srcWidth = srcSize.getWidth();
    final int srcHeight = srcSize.getHeight();
    final int targetWidth = targetSize.getWidth();
    final int targetHeight = targetSize.getHeight();

    final float widthScale = (float) srcWidth / targetWidth;
    final float heightScale = (float) srcHeight / targetHeight;

    final int destWidth;
    final int destHeight;
    if ((viewScaleType == ViewScaleType.FIT_INSIDE && widthScale >= heightScale) || (viewScaleType == ViewScaleType.CROP && widthScale < heightScale)) {
        destWidth = targetWidth;
        destHeight = (int) (srcHeight / widthScale);
    } else {
        destWidth = (int) (srcWidth / heightScale);
        destHeight = targetHeight;
    }

    float scale = 1;
    if ((!stretch && destWidth < srcWidth && destHeight < srcHeight) || (stretch && destWidth != srcWidth && destHeight != srcHeight)) {
        scale = (float) destWidth / srcWidth;
    }

    return scale;
}
项目:GifImageLoader    文件:ImageLoaderConfiguration.java   
ImageSize getMaxImageSize() {
    DisplayMetrics displayMetrics = resources.getDisplayMetrics();

    int width = maxImageWidthForMemoryCache;
    if (width <= 0) {
        width = displayMetrics.widthPixels;
    }
    int height = maxImageHeightForMemoryCache;
    if (height <= 0) {
        height = displayMetrics.heightPixels;
    }
    return new ImageSize(width, height);
}
项目:GifImageLoader    文件:LoadAndDisplayImageTask.java   
/**
 * 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;
}
项目:ImageLoaderSupportGif    文件:ImageSizeUtils.java   
/**
 * Defines target size for image aware view. Size is defined by target
 * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware view} parameters, configuration
 * parameters or device display dimensions.<br />
 */
public static ImageSize defineTargetSizeForView(ImageAware imageAware, ImageSize maxImageSize) {
    int width = imageAware.getWidth();
    if (width <= 0) width = maxImageSize.getWidth();

    int height = imageAware.getHeight();
    if (height <= 0) height = maxImageSize.getHeight();

    return new ImageSize(width, height);
}
项目:ImageLoaderSupportGif    文件:ImageSizeUtils.java   
/**
 * Computes minimal sample size for downscaling image so result image size won't exceed max acceptable OpenGL
 * texture size.<br />
 * We can't create Bitmap in memory with size exceed max texture size (usually this is 2048x2048) so this method
 * calculate minimal sample size which should be applied to image to fit into these limits.
 *
 * @param srcSize Original image size
 * @return Minimal sample size
 */
public static int computeMinImageSampleSize(ImageSize srcSize) {
    final int srcWidth = srcSize.getWidth();
    final int srcHeight = srcSize.getHeight();
    final int targetWidth = maxBitmapSize.getWidth();
    final int targetHeight = maxBitmapSize.getHeight();

    final int widthScale = (int) Math.ceil((float) srcWidth / targetWidth);
    final int heightScale = (int) Math.ceil((float) srcHeight / targetHeight);

    return Math.max(widthScale, heightScale); // max
}
项目:GifImageLoader    文件:NonViewAware.java   
public NonViewAware(String imageUri, ImageSize imageSize, ViewScaleType scaleType) {
    if (imageSize == null) throw new IllegalArgumentException("imageSize must not be null");
    if (scaleType == null) throw new IllegalArgumentException("scaleType must not be null");

    this.imageUri = imageUri;
    this.imageSize = imageSize;
    this.scaleType = scaleType;
}
项目:GifImageLoader    文件:ImageLoadingInfo.java   
public ImageLoadingInfo(String uri, ImageAware imageAware, ImageSize targetSize, String memoryCacheKey,
    DisplayImageOptions options, ImageLoadingListener listener,
    ImageLoadingProgressListener progressListener, ReentrantLock loadFromUriLock) {
this.uri = uri;
this.imageAware = imageAware;
this.targetSize = targetSize;
this.options = options;
this.listener = listener;
this.progressListener = progressListener;
this.loadFromUriLock = loadFromUriLock;
this.memoryCacheKey = memoryCacheKey;

      mFileTypeStatus = BitmapDisplayer.FILE_TYPE_UNDEFINE;
      mFilePath = null;
  }
项目:boohee_v5.6    文件:UILImageLoader.java   
public void displayImage(MQImageView imageView, String path, @DrawableRes int loadingResId,
                         @DrawableRes int failResId, int width, int height, final
                         MQDisplayImageListener displayImageListener) {
    initImageLoader(imageView.getContext());
    if (path == null) {
        path = "";
    }
    if (!(path.startsWith("http") || path.startsWith("file"))) {
        path = "file://" + path;
    }
    String str = path;
    ImageLoader.getInstance().displayImage(str, new ImageViewAware(imageView), new
            DisplayImageOptions.Builder().showImageOnLoading(loadingResId).showImageOnFail
            (failResId).cacheInMemory(true).build(), new ImageSize(width, height), new
            SimpleImageLoadingListener() {
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            if (displayImageListener != null) {
                displayImageListener.onSuccess(view, imageUri);
            }
        }
    }, null);
}
项目:boohee_v5.6    文件:ImageSizeUtils.java   
public static ImageSize defineTargetSizeForView(ImageAware imageAware, ImageSize maxImageSize) {
    int width = imageAware.getWidth();
    if (width <= 0) {
        width = maxImageSize.getWidth();
    }
    int height = imageAware.getHeight();
    if (height <= 0) {
        height = maxImageSize.getHeight();
    }
    return new ImageSize(width, height);
}