Search in sources :

Example 11 with ImageSize

use of com.nostra13.universalimageloader.core.assist.ImageSize in project Android-Universal-Image-Loader by nostra13.

the class BaseImageDecoder method considerExactScaleAndOrientatiton.

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

Example 12 with ImageSize

use of com.nostra13.universalimageloader.core.assist.ImageSize in project QiDict by timqi.

the class MainActivity method setBackgroundColor.

private void setBackgroundColor(int bgNum) {
    int[] bgArr = new int[] { 0, R.drawable.bg1, R.drawable.bg2, R.drawable.bg3, R.drawable.bg4, R.drawable.bg5, R.drawable.bg6, R.drawable.bg7, R.drawable.bg8, R.drawable.bg9, R.drawable.bg10, R.drawable.bg11, R.drawable.bg12 };
    String imgUri = "drawable://" + bgArr[bgNum];
    ImageSize imageSize = new ImageSize(mRelativeLayout.getWidth(), mRelativeLayout.getHeight());
    Bitmap bitmap = ImageLoader.getInstance().loadImageSync(imgUri, imageSize);
    mRelativeLayout.setBackgroundDrawable(new BitmapDrawable(bitmap));
}
Also used : Bitmap(android.graphics.Bitmap) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Aggregations

ImageSize (com.nostra13.universalimageloader.core.assist.ImageSize)11 Bitmap (android.graphics.Bitmap)6 Options (android.graphics.BitmapFactory.Options)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 View (android.view.View)2 RemoteViews (android.widget.RemoteViews)2 ImageScaleType (com.nostra13.universalimageloader.core.assist.ImageScaleType)2 File (java.io.File)2 Intent (android.content.Intent)1 Matrix (android.graphics.Matrix)1 DisplayMetrics (android.util.DisplayMetrics)1 LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)1 ImageDecodingInfo (com.nostra13.universalimageloader.core.decode.ImageDecodingInfo)1 ImageViewAware (com.nostra13.universalimageloader.core.imageaware.ImageViewAware)1 NonViewAware (com.nostra13.universalimageloader.core.imageaware.NonViewAware)1 SimpleImageLoadingListener (com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener)1