本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}