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


Java Options类代码示例

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


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

示例1: getOption

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
/**获取配置
 * @param cornerRadiusSize
 * @param defaultImageResId
 * @return
 */
@SuppressWarnings("deprecation")
private static DisplayImageOptions getOption(int cornerRadiusSize, int defaultImageResId) {
	Options options0 = new Options();
	options0.inPreferredConfig = Bitmap.Config.RGB_565;

	DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
	if(defaultImageResId > 0) {
		try {
			builder.showImageForEmptyUri(defaultImageResId)
			.showImageOnLoading(defaultImageResId)
			.showImageOnFail(defaultImageResId);
		} catch (Exception e) {
			Log.e(TAG, "getOption  try {builder.showImageForEmptyUri(defaultImageResId) ..." +
					" >> } catch (Exception e) { \n" + e.getMessage());
		}
	}
	if (cornerRadiusSize > 0) {
		builder.displayer(new RoundedBitmapDisplayer(cornerRadiusSize));
	}

	return builder.cacheInMemory(true).cacheOnDisc(true).decodingOptions(options0).build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:ImageLoaderUtil.java

示例2: a

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
private Bitmap a(Context context, String str) {
    File file = new File(str);
    if (file.exists()) {
        CompressFormat bmpFormat = BitmapHelper.getBmpFormat(str);
        int dipToPx = R.dipToPx(context, 120);
        if (CompressFormat.PNG == bmpFormat) {
            dipToPx = R.dipToPx(context, 90);
        }
        Bitmap decodeFile = BitmapFactory.decodeFile(str, new Options());
        if (file.length() > this.b) {
            Bitmap bitmap = decodeFile;
            while (dipToPx > 40 && a(bitmap, bmpFormat) > 32768) {
                int i = dipToPx - 5;
                int width = bitmap.getWidth();
                int height = bitmap.getHeight();
                double d = (height > i || width > i) ? height > width ? ((double) i) / ((double) height) : ((double) i) / ((double) width) : PathListView.NO_ZOOM;
                bitmap = Bitmap.createScaledBitmap(bitmap, (int) (((double) width) * d), (int) (d * ((double) height)), true);
                dipToPx = i;
            }
            OutputStream fileOutputStream = new FileOutputStream(File.createTempFile("sina_bm_tmp", "." + bmpFormat.name().toLowerCase()));
            bitmap.compress(bmpFormat, 100, fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
            return bitmap;
        }
        Ln.i("sina weibo decode bitmap size ==>>" + a(decodeFile, bmpFormat), new Object[0]);
        return decodeFile;
    }
    throw new FileNotFoundException();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:31,代码来源:SinaActivity.java

示例3: ImageDecodingInfo

import android.graphics.BitmapFactory.Options; //导入依赖的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

示例4: prepareDecodingOptions

import android.graphics.BitmapFactory.Options; //导入依赖的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

示例5: getScaleBitmap

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
public static Bitmap getScaleBitmap(Context context, String imagePath,
		int maxWidth) {
	try {
		Options bitmapOptions = new Options();
		bitmapOptions.inJustDecodeBounds = true;
		BitmapFactory.decodeFile(imagePath, bitmapOptions);
		int imageWidth = bitmapOptions.outWidth;

		if (maxWidth == 0) {
			maxWidth = DevUtils.getScreenWidth(context);
		} else if (maxWidth < 0) {
			maxWidth = imageWidth;
		}

		if (imageWidth < maxWidth) {
			maxWidth = imageWidth;
		}

		Bitmap bitmap = createScaleBitmapByWidthIfNeed(imagePath, maxWidth);
		return bitmap;
	} catch (OutOfMemoryError e) {
		Log.e("BitmapUtils", "compressBitmap", e);
		return null;
	}
}
 
开发者ID:AnnyBaby,项目名称:Mvp-Retrofit-Rxjava-Rxbus,代码行数:26,代码来源:BitmapUtils.java

示例6: getImageFromAssetFile

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
/**
 * 从系统的asset中读取一张图片 . <br>
 * @author liulongzhenhai 2012-8-1 下午5:21:12 <br>
 * @param context 上下文
 * @param fileName 文件相对路劲
 * @param density Options.inDensity的设置,在一些情况下,需要制定.否则,会变形
 * @return 返回图片
 */
public static Bitmap getImageFromAssetFile(final Context context, final String fileName, final int density) {
	if (TextUtils.isEmpty(fileName)) {
		return null;
	}
	Bitmap image = null;
	try {
		final AssetManager am = context.getAssets();
		final InputStream is = am.open(fileName);
		final Options o = new Options();
		o.inDensity = density;
		image = BitmapFactory.decodeStream(is, null, o);
		is.close();
	} catch (final Exception e) {
	}
	return image;
}
 
开发者ID:VK2012,项目名称:AppCommonFrame,代码行数:25,代码来源:BitmapUtil.java

示例7: copyOptions

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
private void copyOptions(Options srcOptions, Options destOptions) {
    destOptions.inDensity = srcOptions.inDensity;
    destOptions.inDither = srcOptions.inDither;
    destOptions.inInputShareable = srcOptions.inInputShareable;
    destOptions.inJustDecodeBounds = srcOptions.inJustDecodeBounds;
    destOptions.inPreferredConfig = srcOptions.inPreferredConfig;
    destOptions.inPurgeable = srcOptions.inPurgeable;
    destOptions.inSampleSize = srcOptions.inSampleSize;
    destOptions.inScaled = srcOptions.inScaled;
    destOptions.inScreenDensity = srcOptions.inScreenDensity;
    destOptions.inTargetDensity = srcOptions.inTargetDensity;
    destOptions.inTempStorage = srcOptions.inTempStorage;
    if (VERSION.SDK_INT >= 10) {
        copyOptions10(srcOptions, destOptions);
    }
    if (VERSION.SDK_INT >= 11) {
        copyOptions11(srcOptions, destOptions);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:ImageDecodingInfo.java

示例8: decode

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
/**
 * @description:解析Bitmap的公用方法.注意各个方法的参数必须要有options
 * @author:hui-ye
 * @param path
 * @param data
 * @param context
 * @param uri
 * @param options
 * @return:
 */

public static Bitmap decode(String path, byte[] data, Context context, Uri uri,
							Options options) throws Exception {
	Bitmap bitmap = null;
	if (path != null) {
		bitmap = BitmapFactory.decodeFile(path, options);
	} else if (data != null) {
		BitmapFactory.decodeByteArray(data, 0, data.length, options);
	} else if (uri != null) {
		// uri不为空的时候context也不要为空.:ContentResolver;Uri内容解析器
		ContentResolver resolver = context.getContentResolver();
		InputStream is;
		is = resolver.openInputStream(uri);
		bitmap = BitmapFactory.decodeStream(is, null, options);
	}
	System.gc();
	return bitmap;
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:29,代码来源:BitmapUtil.java

示例9: getBitmapOptions

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
public static Options getBitmapOptions(byte[] bArr) {
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeByteArray(bArr, 0, bArr.length, options);
    int ceil = (int) Math.ceil((double) (options.outWidth / UMImage.MAX_WIDTH));
    int ceil2 = (int) Math.ceil((double) (options.outHeight / UMImage.MAX_HEIGHT));
    if (ceil2 <= 1 || ceil <= 1) {
        if (ceil2 > 2) {
            options.inSampleSize = ceil2;
        } else if (ceil > 2) {
            options.inSampleSize = ceil;
        }
    } else if (ceil2 > ceil) {
        options.inSampleSize = ceil2;
    } else {
        options.inSampleSize = ceil;
    }
    options.inJustDecodeBounds = false;
    return options;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:BitmapUtils.java

示例10: prepareDecodingOptions

import android.graphics.BitmapFactory.Options; //导入依赖的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

示例11: decodeAbtoBm

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
public Bitmap decodeAbtoBm(byte[] b, int actualSize) {
    System.gc();
    Runtime.getRuntime().gc();
    Options oo = new Options();
    oo.inJustDecodeBounds = true;
    BitmapFactory.decodeByteArray(b, 0, b.length, oo);
    int scale = 1;
    while ((oo.outWidth / scale) / 2 >= actualSize && (oo.outHeight / scale) / 2 >= actualSize) {
        scale *= 2;
    }
    Options o2 = new Options();
    o2.inSampleSize = scale;
    o2.inPurgeable = true;
    o2.inInputShareable = true;
    Bitmap bm = BitmapFactory.decodeByteArray(b, 0, b.length, o2);
    System.gc();
    Runtime.getRuntime().gc();
    return bm;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:RoundImageView.java

示例12: getBitmapByPath

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
public static Bitmap getBitmapByPath(String filename) {
    if (!checkFileIsEnabledPath(filename)) {
        return null;
    }
    Options newOpts = new Options();
    newOpts.inJustDecodeBounds = true;
    Bitmap bitmap = BitmapFactory.decodeFile(filename, newOpts);
    int w = newOpts.outWidth;
    int h = newOpts.outHeight;
    if (bitmap != null) {
        bitmap.recycle();
    }
    int be = 1;
    if (w > h && ((float) w) > 300.0f) {
        be = (int) (((float) newOpts.outWidth) / 300.0f);
    } else if (w < h && ((float) h) > 400.0f) {
        be = (int) (((float) newOpts.outHeight) / 400.0f);
    }
    if (be <= 0) {
        be = 1;
    }
    Options newOpts2 = new Options();
    newOpts2.inSampleSize = be;
    newOpts2.inJustDecodeBounds = false;
    return BitmapFactory.decodeFile(filename, newOpts2);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:27,代码来源:FileUtils.java

示例13: computeInitialSampleSize

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
private static int computeInitialSampleSize(Options options, int minSideLength, int maxNumOfPixels) {
    double w = (double) options.outWidth;
    double h = (double) options.outHeight;
    int lowerBound = maxNumOfPixels == -1 ? 1 : (int) Math.ceil(Math.sqrt((w * h) / ((double) maxNumOfPixels)));
    int upperBound = minSideLength == -1 ? 128 : (int) Math.min(Math.floor(w / ((double) minSideLength)), Math.floor(h / ((double) minSideLength)));
    if (upperBound < lowerBound) {
        return lowerBound;
    }
    if (maxNumOfPixels == -1 && minSideLength == -1) {
        return 1;
    }
    if (minSideLength != -1) {
        return upperBound;
    }
    return lowerBound;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:FileUtils.java

示例14: b

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
private static final boolean b(String str, int i, int i2) {
    if (TextUtils.isEmpty(str)) {
        return false;
    }
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(str, options);
    int i3 = options.outWidth;
    int i4 = options.outHeight;
    if (options.mCancel || options.outWidth == -1 || options.outHeight == -1) {
        return false;
    }
    int i5 = i3 > i4 ? i3 : i4;
    if (i3 >= i4) {
        i3 = i4;
    }
    f.b("AsynScaleCompressImage", "longSide=" + i5 + "shortSide=" + i3);
    options.inPreferredConfig = Config.RGB_565;
    if (i5 > i2 || i3 > i) {
        return true;
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:24,代码来源:a.java

示例15: a

import android.graphics.BitmapFactory.Options; //导入依赖的package包/类
private Bitmap a(String str) throws IOException {
    int i = 1;
    Options options = new Options();
    options.inJustDecodeBounds = true;
    Uri parse = Uri.parse(str);
    InputStream openInputStream = getContentResolver().openInputStream(parse);
    if (openInputStream == null) {
        return null;
    }
    BitmapFactory.decodeStream(openInputStream, null, options);
    openInputStream.close();
    int i2 = options.outWidth;
    int i3 = options.outHeight;
    while (i2 * i3 > 4194304) {
        i2 /= 2;
        i3 /= 2;
        i *= 2;
    }
    options.inJustDecodeBounds = false;
    options.inSampleSize = i;
    return BitmapFactory.decodeStream(getContentResolver().openInputStream(parse), null, options);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:ImageActivity.java


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