android拍照模糊,解决Android拍照并显示在ImageView中变模糊
该楼层疑似违规已被系统折叠隐藏此楼查看此楼public class ImageThumbnail {public static int reckonThumbnail(int oldWidth, int oldHeight,int newWidth, int newHeight) {if ((oldHeight > newHeight && oldWidth > ne.
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
public class ImageThumbnail {
public static int reckonThumbnail(int oldWidth, int oldHeight,
int newWidth, int newHeight) {
if ((oldHeight > newHeight && oldWidth > newWidth)
|| (oldHeight <= newHeight && oldWidth > newWidth)) {
int be = (int) (oldWidth / (float) newWidth);
if (be <= 1)
be = 1;
return be;
} else if (oldHeight > newHeight && oldWidth <= newWidth) {
int be = (int) (oldHeight / (float) newHeight);
if (be <= 1)
be = 1;
return be;
}
return 1;
}
public static Bitmap PicZoom(Bitmap bmp, int width, int height) {
int bmpWidth = bmp.getWidth();
int bmpHeght = bmp.getHeight();
Matrix matrix = new Matrix();
matrix.postScale((float) width / bmpWidth, (float) height / bmpHeght);
return Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeght, matrix, true);
}
public static String savaPhotoToLocal(Intent data, Bitmap btp) {
// 如果文件夹不存在则创建文件夹,并将bitmap图像文件保存
String filename = System.currentTimeMillis() + ".jpg";
File tempFile = new File(SgsCons.ROOT_DIR, filename);
String filePath = tempFile.getAbsolutePath();
try {
// 将bitmap转为jpg文件保存
FileOutputStream fileOut = new FileOutputStream(tempFile);
btp.compress(CompressFormat.JPEG, 100, fileOut);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return filePath;
}
}
public class ImageThumbnail {
public static int reckonThumbnail(int oldWidth, int oldHeight,
int newWidth, int newHeight) {
if ((oldHeight > newHeight && oldWidth > newWidth)
|| (oldHeight <= newHeight && oldWidth > newWidth)) {
int be = (int) (oldWidth / (float) newWidth);
if (be <= 1)
be = 1;
return be;
} else if (oldHeight > newHeight && oldWidth <= newWidth) {
int be = (int) (oldHeight / (float) newHeight);
if (be <= 1)
be = 1;
return be;
}
return 1;
}
public static Bitmap PicZoom(Bitmap bmp, int width, int height) {
int bmpWidth = bmp.getWidth();
int bmpHeght = bmp.getHeight();
Matrix matrix = new Matrix();
matrix.postScale((float) width / bmpWidth, (float) height / bmpHeght);
return Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeght, matrix, true);
}
public static String savaPhotoToLocal(Intent data, Bitmap btp) {
// 如果文件夹不存在则创建文件夹,并将bitmap图像文件保存
String filename = System.currentTimeMillis() + ".jpg";
File tempFile = new File(SgsCons.ROOT_DIR, filename);
String filePath = tempFile.getAbsolutePath();
try {
// 将bitmap转为jpg文件保存
FileOutputStream fileOut = new FileOutputStream(tempFile);
btp.compress(CompressFormat.JPEG, 100, fileOut);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return filePath;
}
}
更多推荐
所有评论(0)