【Android初学第78天】弓背霞明剑照霜,秋风走马出咸阳。这篇文章主要讲述Android初学第78天相关的知识,希望能为你提供帮助。
android初学第78天16_CameraIntent
代码
Criminalintent
PictureUtils.java
package com.bignerdranch.android.criminalintent;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
public class PictureUtils {
public static Bitmap getScaledBitmap(String path, Activity activity) {
Point size = new Point();
activity.getWindowManager().getDefaultDisplay()
.getSize(size);
return getScaledBitmap(path, size.x, size.y);
}public static Bitmap getScaledBitmap(String path, int destWidth, int destHeight) {
// Read in the dimensions of the image on disk
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);
float srcWidth = options.outWidth;
float srcHeight = options.outHeight;
// Figure out how much to scale down by
int inSampleSize = 1;
if (srcHeight >
destHeight || srcWidth >
destWidth) {
float heightScale = srcHeight / destHeight;
float widthScale = srcWidth / destWidth;
inSampleSize = Math.round(heightScale >
widthScale ? heightScale :
widthScale);
}options = new BitmapFactory.Options();
options.inSampleSize = inSampleSize;
// Read in and create final bitmap
return BitmapFactory.decodeFile(path, options);
}
}
推荐阅读
- Android初学第76天
- usb怎样安装系统,本文教您电脑怎样安装系统
- u盘格式化单位分配,本文教您u盘格式化分配单元大小
- 如何制作u盘系统安装盘,本文教您如何制作u盘打开盘
- usb打开,本文教您华硕笔记本怎样设置u盘打开
- usb接口,本文教您电脑usb接口没反应
- 制作u盘系统安装盘,本文教您如何制作u盘打开安装盘
- usb端口,本文教您如何禁用USB接口
- usb2.0与3.0的区别,本文教您电脑usb2.0与3.0的有啥区别