android拍照模糊,解决Android拍照并显示在ImageView中变模糊
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
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;
}
}
android拍照模糊,解决Android拍照并显示在ImageView中变模糊相关推荐
- [Android] 拍照、截图、保存并显示在ImageView控件中
最近在做Android的项目,其中部分涉及到图像处理的内容.这里先讲述如何调用Camera应用程序进行拍照,并截图和保存显示在ImageView控件中以及遇到的困难和解决方法. PS:作者购买 ...
- Android中实现调用摄像头拍照并显示在ImageView中
场景 点击拍照按钮调用系统摄像机进行拍照,并将拍的照片显示在ImageView中. 注: 博客: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的 ...
- Android中从assets资源中读取图片文件并保存到内部存储器并加载显示在ImageView中
场景 Android系统为每个新设计的程序提供了/assets目录,这个目录保存的文件可以打包在程序里./res和/assets的不同点是,android不为/assets下的文件生成ID.如果使用/ ...
- 【android studio】解决android studio drawable新建项目时只有一个drawable目录的问题
[android studio]解决android studio drawable新建项目时只有一个drawable目录的问题 参考文章: (1)[android studio]解决android s ...
- android显示通知图标大全,Android推送通知:图标未显示在通知中,而是显示白色方块...
Android推送通知:图标未显示在通知中,而是显示白色方块 我的应用会生成通知,但我没有显示为该通知设置的图标.相反,我得到一个白色方块. 我已经尝试调整图标的大小(尺寸720x720,66x66, ...
- 原生android 推送图标白色,Android推送通知:图标未显示在通知中,而是显示白色方块...
Android推送通知:图标未显示在通知中,而是显示白色方块 我的应用会生成通知,但我没有显示为该通知设置的图标.相反,我得到一个白色方块. 我已经尝试调整图标的大小(尺寸720x720,66x66, ...
- android通过访问相册获取图片并展示在ImageView中
第一步:添加相应的权限以及属性: ①在manifest中设置权限 <uses-feature android:name="android.hardware.camera" / ...
- android访问图库,android通过访问相册获取图片并展示在ImageView中
第一步:添加相应的权限以及属性: ①在manifest中设置权限 ②在中设置相应属性,这一步很关键,解决了我在这一方面最后的一个有关deny的权限问题 android:requestLegacyExt ...
- Android 7.0 获取相机拍照图片,适配三星手机拍照,解决三星手机拍照屏幕旋转,判断设备是否有摄像头
方法1 新建/res/xml/file_paths: <?xml version="1.0" encoding="utf-8"?> <path ...
最新文章
- Linux内核系统时钟管理 感想总结 (未完待续)
- 计算机键盘是编码键盘还是非编码键盘,矩阵按键原理图_矩阵按键扫描实例
- numpy dot()函数(两个数组的点积)(对于二维阵列,它是矩阵乘积)
- 关于HTTP中40X和50X的问题(介绍,可根据介绍找出问题解决方案)
- multinorm r语言_与心理学数据分析相关的R工具包
- svg载入html,SVG系列教程:SVG简介与嵌入HTML页面的方式
- yum mysql 版本低_mysql小版本升级(yum方式)
- Qt工作笔记-UDP多线程数据处理及发送(简单实例)
- jpa 托管_java – jpa非托管实体
- MariaDB10.2.6启用Mroonga存储引擎用于全文索引
- DevOpsSOP 基于阿里云VPC搭建Storm+Kafka+Zookeeper集群
- 异常:Invalid or unexpected token
- 行内元素(HTML、CSS)
- Python学习笔记--Python字符串连接方法总结
- (转)比特币王国的内战与分裂|《财经》特稿
- Mysql查询字段去除指定列重复数据
- 【SQL注入】CTF练习题WriteUp——“百度杯”CTF比赛 九月场SQL
- 特邀嘉宾-著名主持人李艾“每一次登台都是一次成长
- 什么是RBER(残余误比特率)FER(帧删除率)BER(误比特率)
- Error in sitecustomize; set PYTHONVERBOSE for traceback: NameError: name 'modules_list' is not defin
热门文章
- matlab匿名函数解方程,matlab 数学建模 匿名函数@
- Uncaught ReferenceError: onclick is not defined
- 基于node.js的第三方模块(itheima-tools-djh)
- USB CAN使用手册
- c#开发电子商务网站---我的笔记
- electron-vue项目构建打包错误失败问题合集
- WireShark 无法抓取以太帧前序和FCS或出现IP报头校验和错误 -- 原因
- Qdiscs配置TSN网络
- OMAPL138upp
- 中文翻译Introduction to Linear Algebra, 5th Edition 5.2