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


Java ImageSize类代码示例

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


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

示例1: ImageDecodingInfo

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

示例2: prepareDecodingOptions

import com.nostra13.universalimageloader.core.assist.ImageSize; //导入依赖的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

示例3: computeImageScale

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

示例4: resizeAndSaveImage

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

示例5: prepareDecodingOptions

import com.nostra13.universalimageloader.core.assist.ImageSize; //导入依赖的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

示例6: computeImageScale

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

示例7: defineImageSizeAndRotation

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

示例8: prepareDecodingOptions

import com.nostra13.universalimageloader.core.assist.ImageSize; //导入依赖的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

示例9: getTargetSize

import com.nostra13.universalimageloader.core.assist.ImageSize; //导入依赖的package包/类
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);
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:18,代码来源:WallpaperHelper.java

示例10: computeMinImageSampleSize

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

示例11: computeImageScale

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

示例12: getMaxImageSize

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

示例13: resizeAndSaveImage

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

示例14: defineImageSizeAndRotation

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

示例15: considerExactScaleAndOrientatiton

import com.nostra13.universalimageloader.core.assist.ImageSize; //导入依赖的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


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