/**
* 计算图片的缩放值
*
* @param options
* @param reqWidth
* @param reqHeight
* @return
*/
public static int calculateInSampleSize(BitmapFactory.Options options,
int reqWidth, int reqHeight) {
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int heightRatio = Math.round((float) height
/ (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
}
/**
* 根据路径获得突破并压缩返回bitmap用于显示
*
* @param imagesrc
* @return
*/
@SuppressWarnings("static-access")
public static Bitmap getSmallBitmap(String filePath) {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath, options);
options.inSampleSize = calculateInSampleSize(options, 480, 800);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(filePath, options);
}
/**
* 根据路径删除图片
*
* @param path
*/
public static void deleteTempFile(String path) {
File file = new File(path);
if (file.exists()) {
file.delete();
}
}
上传图片防止图片失真模糊
时间: 2024-08-27 18:05:18
上传图片防止图片失真模糊的相关文章
jquery实现上传图片及图片大小验证、图片预览效果代码
jquery实现上传图片及图片大小验证.图片预览效果代码 上传图片验证 */ function submit_upload_picture(){ var file = $('file_c').value; if(!/.(gif|jpg|jpeg|png|gif|jpg|png)$/.test(file)){ alert("图片类型必须是.gif,jpeg,jpg,png中的一种") }else{ $('both_form')
kindeditor扩展粘贴图片功能&;修改图片上传路径并通过webapi上传图片到图片服务器
前言 kindeditor是一个非常好用的富文本编辑器,它的简单使用我就不再介绍了. 而kindeditor却对图片的处理不够理想. 本篇博文需要解决的问题有两个: kindeditor扩展粘贴图片功能 kindeditor修改图片上传路径并通过webapi上传图片到图片服务器(支持分布式图片) 结果演示 1.扩展粘贴图片功能演示 2.修改图片上传路径演示: 我们的网站演示地址是:http://localhost:9393/ 我们的图片服务器地址是:http://localhost:9394/
iOS 让图片变模糊
#import <Accelerate/Accelerate.h> 1.初始化图片 UIImageView *iv = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds]; [iv setImage:[self blurryImage:[UIImage imageNamed:@"welcome_2.jpg"] withBlurLevel:0.6]]; [self.view addSubview:iv
基于HTML5 Canvas实现的图片马赛克模糊特效
效果请点击下面网址: http://hovertree.com/texiao/html5/1.htm 一.开门见山受美国肖像画家Chuck Close的启发,此脚本通过使用HTML5 canvas元素把图像转换成像素形式,这基本上是一个为canvas imageData功能的简单演示. 此脚本现存于GitHub上,您可以在那里下载到脚本和示例.在GitHub上查看像素化资源 二.选项此方法接受一个对象数组,每个对象都拥有一组选项.resolution : 渲染像素间的像素距离,必须的.shape
HTML5 Canvas实现的图片马赛克模糊特效
要想让图片像素化,首先调用如下脚本:<script type="text/javascript" src="http://hovertree.com/texiao/html5/1/js/close-pixelate.js"></script>然后调用方法closePixelate,更具体的是:图片dom.closePixelate(选项参数) 此脚本可以应用于各类图片.根据HTML5规范,浏览器禁止任何外部托管图片上使用getImageDat
小程序图片失真解决办法
解决办法: 一: 此办法不仅仅是针对小程序,适用于支持CSS3属性的浏览器. 将图片设置为配景图片.img { background:url('') no-repeat; background-size:cover //此属性是是把背景扩充到足够大,使背景图像完全覆盖背景区域.背景图像的某些部分也许永远无法显示在背景定位区域中 } 二: <image src=""></image>图片失真 以Iphone的宽度和高度为基准,将原图片的宽度和高度扩大2倍,单位写成
flash无法找到类接口和图片失真问题。
刚写的,直接刷没了.0-0 看问题. 公司升级软件,但是,再使用原来的模板和类后,系统报错:无法找到类接口. 整整一篇. 但是我进去看了代码,使用了import和include,那到底是那里错了呢? 后来测试发现是发布设置的问题. 文件->发布设置 然后问题解决. 但是我发现,这个问题不是绝对的,看情况而定. 第二个问题,图片失真. 导出影片后,发现图像和文字变形失真,这怎么办啊,那客户能满意能给钱吗?! 我们都知道,图片导入flash后,默认会变成位图,而且压缩了很多,这其实是没有问题的.因为
IOS 图片失真
1. 问题:图片过小,需要放大到合适尺寸 //对图片进行压缩 defaultStatusImg1 = [self scaleImage:defaultStatusImg1 toScale:1.5f]; 2. 问题:图片失真 //图片失真 defaultStatusImg1 = [UIImage_Extend imageWithColor:[UIColor clearColor] withImage:defaultStatusImg1 withSize:itemRect.size withOff
CDC的StretchBlt函数载入位图时图片失真问题
最近遇到加载的bmp图片出现失真问题,查找得知需要用SetStretchBltMode函数设置拉伸模式. 函数原型:int SetSTretchBltMode(HDC hdc, int iStretchMode) 参数: hdc:设备环境句柄. LStretchMode:指定拉伸模式.它可以取下列值,这些值的含义如下: BLACKONWHITE:使用消除和现在的像素颜色值进行逻辑AND(与)操作运算.如果该位图是单色位图,那么该模式以牺牲白色像素为代价,保留黑色像素点. COLORONCOLOR