本文整理汇总了Java中com.nostra13.universalimageloader.core.assist.ImageSize.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ImageSize.getWidth方法的具体用法?Java ImageSize.getWidth怎么用?Java ImageSize.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nostra13.universalimageloader.core.assist.ImageSize
的用法示例。
在下文中一共展示了ImageSize.getWidth方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: defineTargetSizeForView
import com.nostra13.universalimageloader.core.assist.ImageSize; //导入方法依赖的package包/类
/**
* 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);
}
示例4: 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
}
示例5: 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;
}
示例6: defineTargetSizeForView
import com.nostra13.universalimageloader.core.assist.ImageSize; //导入方法依赖的package包/类
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);
}
示例7: computeImageSampleSize
import com.nostra13.universalimageloader.core.assist.ImageSize; //导入方法依赖的package包/类
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);
}
示例8: computeMinImageSampleSize
import com.nostra13.universalimageloader.core.assist.ImageSize; //导入方法依赖的package包/类
public static int computeMinImageSampleSize(ImageSize srcSize) {
int srcWidth = srcSize.getWidth();
int srcHeight = srcSize.getHeight();
return Math.max((int) Math.ceil((double) (((float) srcWidth) / ((float) maxBitmapSize
.getWidth()))), (int) Math.ceil((double) (((float) srcHeight) / ((float)
maxBitmapSize.getHeight()))));
}
示例9: updateWallpapers
import com.nostra13.universalimageloader.core.assist.ImageSize; //导入方法依赖的package包/类
public void updateWallpapers(@NonNull List<Wallpaper> wallpapers) {
if (!openDatabase()) {
LogUtil.e("Database error: updateWallpapers() failed to open database");
return;
}
String query = "UPDATE " +TABLE_WALLPAPERS+ " SET " +KEY_FAVORITE+ " = ?, " +KEY_SIZE+ " = ?, "
+KEY_MIME_TYPE+ " = ?, " +KEY_WIDTH+ " = ?," +KEY_HEIGHT+ " = ?, " +KEY_COLOR+ " = ? "
+"WHERE " +KEY_URL+ " = ?";
SQLiteStatement statement = mDatabase.get().mSQLiteDatabase.compileStatement(query);
mDatabase.get().mSQLiteDatabase.beginTransaction();
for (Wallpaper wallpaper : wallpapers) {
statement.clearBindings();
statement.bindLong(1, wallpaper.isFavorite() ? 1 : 0);
statement.bindLong(2, wallpaper.getSize());
String mimeType = wallpaper.getMimeType();
if (mimeType != null) {
statement.bindString(3, mimeType);
} else {
statement.bindNull(3);
}
ImageSize dimension = wallpaper.getDimensions();
int width = dimension == null ? 0 : dimension.getWidth();
int height = dimension == null ? 0 : dimension.getHeight();
statement.bindLong(4, width);
statement.bindLong(5, height);
statement.bindLong(6, wallpaper.getColor());
statement.bindString(7, wallpaper.getUrl());
statement.execute();
}
mDatabase.get().mSQLiteDatabase.setTransactionSuccessful();
mDatabase.get().mSQLiteDatabase.endTransaction();
}
示例10: computeMinImageSampleSize
import com.nostra13.universalimageloader.core.assist.ImageSize; //导入方法依赖的package包/类
public static int computeMinImageSampleSize(ImageSize srcSize) {
int srcWidth = srcSize.getWidth();
int srcHeight = srcSize.getHeight();
return Math.max((int) Math.ceil((double) (((float) srcWidth) / ((float) maxBitmapSize.getWidth()))), (int) Math.ceil((double) (((float) srcHeight) / ((float) maxBitmapSize.getHeight()))));
}
示例11: generateKey
import com.nostra13.universalimageloader.core.assist.ImageSize; //导入方法依赖的package包/类
public static String generateKey(String imageUri, ImageSize targetSize) {
return "_" + targetSize.getWidth() + WIDTH_AND_HEIGHT_SEPARATOR + targetSize.getHeight();
}
示例12: generateKey
import com.nostra13.universalimageloader.core.assist.ImageSize; //导入方法依赖的package包/类
public static String generateKey(String imageUri, ImageSize targetSize) {
return URI_AND_SIZE_SEPARATOR + targetSize.getWidth() + WIDTH_AND_HEIGHT_SEPARATOR +
targetSize.getHeight();
}