当前位置: 首页>>代码示例>>Java>>正文


Java ImageSizeUtils类代码示例

本文整理汇总了Java中com.nostra13.universalimageloader.utils.ImageSizeUtils的典型用法代码示例。如果您正苦于以下问题:Java ImageSizeUtils类的具体用法?Java ImageSizeUtils怎么用?Java ImageSizeUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ImageSizeUtils类属于com.nostra13.universalimageloader.utils包,在下文中一共展示了ImageSizeUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareDecodingOptions

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BaseImageDecoder.java

示例2: prepareDecodingOptions

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:25,代码来源:BaseImageDecoder.java

示例3: prepareDecodingOptions

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:BaseImageDecoder.java

示例4: tryLoadBitmap

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
Bitmap tryLoadBitmap(ImageViewAware imageAware) {
    Bitmap bitmap = null;
    try {
        java.io.File imageFile = diskCache.get(getMessage().get_id());
        if (imageFile != null && imageFile.exists() && imageFile.length() > 0) {
            ViewScaleType viewScaleType = imageAware.getScaleType();
            ImageSize imageSize = ImageSizeUtils.defineTargetSizeForView(imageAware, new ImageSize(MainApp.CONTEXT.getResources().getDisplayMetrics().widthPixels, MainApp.CONTEXT.getResources().getDisplayMetrics().heightPixels));
            ImageDecodingInfo decodingInfo = new ImageDecodingInfo(getMessage().get_id(),
                    ImageDownloader.Scheme.FILE.wrap(imageFile.getAbsolutePath()), getMessage().get_id(), imageSize, viewScaleType,
                    new BaseImageDownloader(MainApp.CONTEXT), options);
            bitmap = decoder.decode(decodingInfo);
            MainApp.memoryCache.put(getMessage().get_id(), bitmap);
        }
    } catch (Exception ignored) {
        ignored.printStackTrace();
    }
    return bitmap;
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:19,代码来源:VideoRow.java

示例5: prepareDecodingOptions

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
protected BitmapFactory.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());
    }

    BitmapFactory.Options decodingOptions = decodingInfo.getDecodingOptions();
    decodingOptions.inSampleSize = scale;
    return decodingOptions;
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:21,代码来源:DiskDecoder.java

示例6: prepareDecodingOptions

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
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;
}
 
开发者ID:BigAppOS,项目名称:BigApp_WordPress_Android,代码行数:21,代码来源:BaseImageDecoder.java

示例7: prepareDecodingOptions

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
	ImageScaleType scaleType = decodingInfo.getImageScaleType();
	int scale;
	if (scaleType == ImageScaleType.NONE) {
		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;
}
 
开发者ID:x251089003,项目名称:EveryXDay,代码行数:19,代码来源:BaseImageDecoder.java

示例8: prepareDecodingOptions

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
	ImageScaleType scaleType = decodingInfo.getImageScaleType();
	int scale;
	if (scaleType == ImageScaleType.NONE) {
		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_SABSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
	}

	Options decodingOptions = decodingInfo.getDecodingOptions();
	decodingOptions.inSampleSize = scale;
	return decodingOptions;
}
 
开发者ID:Apokrif,项目名称:morse,代码行数:19,代码来源:BaseImageDecoder.java

示例9: considerExactScaleAndOrientatiton

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:BaseImageDecoder.java

示例10: testGetImageSizeScaleTo_useImageActualSize

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
@Test
public void testGetImageSizeScaleTo_useImageActualSize() throws Exception {
	// We layout the view to give it a width and height
	mView.measure(View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY));
	mView.layout(0, 0, 200, 200);

	ImageSize expected = new ImageSize(200, 200);
	ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(590, 590));
	Assertions.assertThat(result).isNotNull();
	Assertions.assertThat(result.getWidth()).isEqualTo(expected.getWidth());
	Assertions.assertThat(result.getHeight()).isEqualTo(expected.getHeight());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ImageSizeTest.java

示例11: testGetImageSizeScaleTo_dontUseImageActualSizeWithWrapContent

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
/**
 * This will make sure the view falls back to the ViewParams/Max/Or Config if wrap content so that it is never
 * shrunk to the first image size. In this case it falls back to the config size
 * 
 * @throws Exception
 */
@Test
public void testGetImageSizeScaleTo_dontUseImageActualSizeWithWrapContent() throws Exception {
	//Set it to wrap content so that it will fall back to
	mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
	mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
	// We layout the view to give it a width and height
	mView.layout(0, 0, 200, 200);

	ImageSize expected = new ImageSize(500, 500);
	ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500));
	Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ImageSizeTest.java

示例12: testGetImageSizeScaleTo_useImageLayoutParams

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
@Test
public void testGetImageSizeScaleTo_useImageLayoutParams() throws Exception {
	// Set a defined width
	mView.setLayoutParams(new FrameLayout.LayoutParams(300, 300));

	ImageSize expected = new ImageSize(300, 300);
	ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500));
	Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ImageSizeTest.java

示例13: testComputeImageSampleSize_fitInside

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
@Test
public void testComputeImageSampleSize_fitInside() throws Exception {
	final ViewScaleType scaleType = ViewScaleType.FIT_INSIDE;
	int result;

	ImageSize srcSize = new ImageSize(300, 100);
	ImageSize targetSize = new ImageSize(30, 10);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(10);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(8);

	srcSize = new ImageSize(300, 100);
	targetSize = new ImageSize(200, 200);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(1);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(1);

	srcSize = new ImageSize(300, 100);
	targetSize = new ImageSize(55, 40);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(5);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(4);

	srcSize = new ImageSize(300, 100);
	targetSize = new ImageSize(30, 40);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(10);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(8);

	srcSize = new ImageSize(5000, 70);
	targetSize = new ImageSize(2000, 30);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(3);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(4);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:ImageSizeTest.java

示例14: testComputeImageSampleSize_centerCrop

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
@Test
public void testComputeImageSampleSize_centerCrop() throws Exception {
	final ViewScaleType scaleType = ViewScaleType.CROP;
	int result;

	ImageSize srcSize = new ImageSize(300, 100);
	ImageSize targetSize = new ImageSize(30, 10);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(10);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(8);

	srcSize = new ImageSize(300, 100);
	targetSize = new ImageSize(200, 200);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(1);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(1);

	srcSize = new ImageSize(300, 100);
	targetSize = new ImageSize(55, 40);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(2);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(2);

	srcSize = new ImageSize(300, 100);
	targetSize = new ImageSize(30, 30);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(3);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(2);

	srcSize = new ImageSize(5000, 70);
	targetSize = new ImageSize(300, 30);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, false);
	Assertions.assertThat(result).isEqualTo(3);
	result = ImageSizeUtils.computeImageSampleSize(srcSize, targetSize, scaleType, true);
	Assertions.assertThat(result).isEqualTo(4);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:ImageSizeTest.java

示例15: considerExactScaleAndOrientatiton

import com.nostra13.universalimageloader.utils.ImageSizeUtils; //导入依赖的package包/类
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo, int rotation, boolean flipHorizontal) {
    Matrix m = new Matrix();
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
        float scale = ImageSizeUtils.computeImageScale(new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation), decodingInfo.getTargetSize(), decodingInfo.getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED);
        if (Float.compare(scale, 1.0f) != 0) {
            m.setScale(scale, scale);
            if (this.loggingEnabled) {
                L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), Float.valueOf(scale), decodingInfo.getImageKey());
            }
        }
    }
    if (flipHorizontal) {
        m.postScale(-1.0f, 1.0f);
        if (this.loggingEnabled) {
            L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
        }
    }
    if (rotation != 0) {
        m.postRotate((float) rotation);
        if (this.loggingEnabled) {
            L.d(LOG_ROTATE_IMAGE, Integer.valueOf(rotation), decodingInfo.getImageKey());
        }
    }
    Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), m, true);
    if (finalBitmap != subsampledBitmap) {
        subsampledBitmap.recycle();
    }
    return finalBitmap;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:31,代码来源:BaseImageDecoder.java


注:本文中的com.nostra13.universalimageloader.utils.ImageSizeUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。