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


Java FloatMath.floor方法代码示例

本文整理汇总了Java中android.util.FloatMath.floor方法的典型用法代码示例。如果您正苦于以下问题:Java FloatMath.floor方法的具体用法?Java FloatMath.floor怎么用?Java FloatMath.floor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.util.FloatMath的用法示例。


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

示例1: loadImage

import android.util.FloatMath; //导入方法依赖的package包/类
public static Bitmap loadImage(Context context, int resId, int imgWidth, int imgHeight){
	Options opts = new Options();
	opts.inJustDecodeBounds = true;
	BitmapFactory.decodeResource(context.getResources(), resId, opts);
	final int height = opts.outHeight;
	final int width = opts.outWidth;
	int inSampleSize = 1;
	if (height > imgHeight || width > imgWidth) {
		if (width > height) {
			inSampleSize = (int) FloatMath
					.floor(((float) height / imgHeight) + 0.5f); // Math.round((float)height
		} else {
			inSampleSize = (int) FloatMath
					.floor(((float) width / imgWidth) + 0.5f); // Math.round((float)width
		}
	}
	opts.inSampleSize = inSampleSize;
	opts.inJustDecodeBounds = false;
	System.out.println("得到的缩放比例为:" + inSampleSize);
	Bitmap copyImg = BitmapFactory.decodeResource(context.getResources(), resId, opts);
	return copyImg;
}
 
开发者ID:dyzs,项目名称:YinjiImageEditor,代码行数:23,代码来源:BitmapUtils.java

示例2: getSampledBitmap

import android.util.FloatMath; //导入方法依赖的package包/类
public static Bitmap getSampledBitmap(String filePath, int reqWidth, int reqHeight) {		
	Options options = new Options();
	options.inJustDecodeBounds = true;
	
	BitmapFactory.decodeFile(filePath, options);
	
	// Raw height and width of image
    final int height = options.outHeight;
    final int width = options.outWidth;
    int inSampleSize = 1;

    if (height > reqHeight || width > reqWidth) {
        if (width > height) {
            inSampleSize = (int)FloatMath.floor(((float)height / reqHeight)+0.5f); //Math.round((float)height / (float)reqHeight);
        } else {
            inSampleSize = (int)FloatMath.floor(((float)width / reqWidth)+0.5f); //Math.round((float)width / (float)reqWidth);
        }
    }
    
    options.inSampleSize = inSampleSize;
    options.inJustDecodeBounds = false;
    	    
    return BitmapFactory.decodeFile(filePath, options);
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:25,代码来源:BitmapUtils.java

示例3: getSampledBitmap

import android.util.FloatMath; //导入方法依赖的package包/类
public static Bitmap getSampledBitmap(String filePath, int reqWidth, int reqHeight)
{
	Options options = new Options();
	options.inJustDecodeBounds = true;

	BitmapFactory.decodeFile(filePath, options);

	// Raw height and width of image
	final int height = options.outHeight;
	final int width = options.outWidth;
	int inSampleSize = 1;

	if (height > reqHeight || width > reqWidth)
	{
		if (width > height)
		{
            inSampleSize = (int)FloatMath.floor(((float)height / reqHeight)+0.5f); //Math.round((float)height / (float)reqHeight);
		}
		else
		{
            inSampleSize = (int)FloatMath.floor(((float)width / reqWidth)+0.5f); //Math.round((float)width / (float)reqWidth);
		}
	}

	options.inSampleSize = inSampleSize;
	options.inJustDecodeBounds = false;

	return BitmapFactory.decodeFile(filePath, options);
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:30,代码来源:BitmapUtils.java

示例4: getSampledBitmap

import android.util.FloatMath; //导入方法依赖的package包/类
/**
 * @param filePath	this is a file absolute path
 * @param reqWidth	bitmap can be scale according this params
 * @param reqHeight bitmap can be scale according this params
 * @return
 */
public static Bitmap getSampledBitmap(String filePath, int reqWidth,
		int reqHeight) {
	Options options = new Options();
	options.inJustDecodeBounds = true;

	BitmapFactory.decodeFile(filePath, options);

	// Raw height and width of image
	final int height = options.outHeight;
	final int width = options.outWidth;
	int inSampleSize = 1;

	if (height > reqHeight || width > reqWidth) {
		if (width > height) {
			inSampleSize = (int) FloatMath
					.floor(((float) height / reqHeight) + 0.5f);
		} else {
			inSampleSize = (int) FloatMath
					.floor(((float) width / reqWidth) + 0.5f);
		}
	}
	// System.out.println("inSampleSize--->" + inSampleSize);

	options.inSampleSize = inSampleSize;
	options.inJustDecodeBounds = false;

	return BitmapFactory.decodeFile(filePath, options);
}
 
开发者ID:dyzs,项目名称:YinjiImageEditor,代码行数:35,代码来源:BitmapUtils.java

示例5: isReadyForPullEnd

import android.util.FloatMath; //导入方法依赖的package包/类
@Override
protected boolean isReadyForPullEnd() {
	float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale());
	return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight());
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:6,代码来源:PullToRefreshWebView.java


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