iOS qrcode 默认尺寸与修改
四种容错格式的尺寸:27、31、31、35.
// 5、将CIImage转换成UIImage,并放大显示
UIImage *imagex = [UIImage imageWithCIImage:outputImage];
NSLog(@"%f", imagex.size.height);
因为生成的二维码是一个CIImage,我们直接转换成UIImage的话大小不好控制,所以使用下面方法返回需要大小的UIImage:
- (UIImage *)createNonInterpolatedUIImageFormCIImage:(CIImage *)image withSize:(CGFloat) size {
CGRect extent = CGRectIntegral(image.extent);
CGFloat scale = MIN(size/CGRectGetWidth(extent), size/CGRectGetHeight(extent));
// 创建bitmap;
size_t width = CGRectGetWidth(extent) * scale;
size_t height = CGRectGetHeight(extent) * scale;
CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef bitmapImage = [context createCGImage:image fromRect:extent];
CGContextSetInterpolationQuality(bitmapRef, kCGInterpolationNone);
CGContextScaleCTM(bitmapRef, scale, scale);
CGContextDrawImage(bitmapRef, extent, bitmapImage);
// 保存bitmap到图片
CGImageRef scaledImage = CGBitmapContextCreateImage(bitmapRef);
CGContextRelease(bitmapRef);
CGImageRelease(bitmapImage);
return [UIImage imageWithCGImage:scaledImage];
}
iOS qrcode 默认尺寸与修改的更多相关文章
- iOS中默认样式修改-b
项目中有大量的UITableView都需要显示sectionHeader.iOS中默认sessionHeader上的textLabel样式跟设计图不符. 按照我们之前的解决方案,是在每个UITable ...
- Android之拨号界面图片风格,无信息默认显示界面修改
Android之拨号界面图片风格,无信息默认显示界面修改 点开Dialer app,出现拨号,联系人,收藏三个选项卡,也就是三个Fragment,在三个界面都没有信息的时候会显示一个时钟,联系人,收藏 ...
- APP One Link ,android and ios qrcode merge as One QRCode and one short link
Adroid and ios qrcode merge as One QRCode and one short link is publish , the web site is www.appone ...
- canvas的默认尺寸
canvas一直就是偶尔看看,随便画点小东西,没有认真琢磨过,今天打算认真的从头学一下,画线的时候感觉坐标不太正常,后来发现,canvas有自己的默认尺寸 写法如下 <canvas id=&qu ...
- iOS设备的尺寸
iOS设备的尺寸有两种统计单位:像素和点,对于程序员来说,只需要记住点即可. 常见的iOS设备的尺寸(点) 分辨率(点) 设备 分辨率(像素) 320*480 4.4s 320*480(4) 640* ...
- Android 系统默认参数的修改
转自: http://www.th7.cn/Program/Android/201505/447097.shtml 写在前面的话 一般在新项目开始之初,我们需要针对客户需求进行各种系统默认属性的配置, ...
- ios UIWebView截获html并修改便签内容(转载)
ios UIWebView截获html并修改便签内容 博客分类: iphone开发iphone开发phoneGap uiwebviewstringByEvaluatingJavaScriptFromS ...
- IOS获取物理尺寸中7Plus中获取的是7的物理尺寸
IOS获取物理尺寸中7Plus中获取的是7的物理尺寸: 在开发调试过程中我的7Plus手机获取[uiscreen mainscreen].bounds为750 .1334. 解决方案:在手机中的显示 ...
- ubuntu16.04 Docker默认存储路径修改
Ubuntu 16.04 Docker默认存储路径修改
随机推荐
- python 英文字串首字母改为大写
#英文字串首字母改为大写 st = "string" St = st[0].upper() + st[1:] 2016-10-22 后来了解到 python 内部有相关实现,感觉 ...
- 一键系统优化15项脚本,适用于Centos6.x
#!/bin/sh ################################################ #Author:nulige # qqinfo:1034611705 # Date ...
- Fragment 与Activity之间的通信
1.Fragment-->Activity 在fragment中的onAttach()中引用Activity实现的接口实例. 2Activity-->Fragment 直接调用 3多个Fr ...
- 修改placehosder
CSS美化INPUT placeholder效果.CSS代码美化文本框里的placeholder文字. ::selection伪元素 简而言之:单冒号(:)用于CSS3伪类,双冒号(::)用于CSS3 ...
- HttpServletRequest 转换成MultipartHttpServletRequest
//转换 HttpServletRequestMultipartHttpServletRequest mulReq=(MultipartHttpServletRequest)request;//获取上 ...
- FragmentStatePageradapter 与 FragmentPageradapter的区别
FragmentPageradapter : 会将fragment储存在内存中 每次加载页面读取内存中的fragment FragmentStatePageradapter: 不会将fragment储 ...
- PHP 解析 ElasticSearch 的 json 方法,有關遍歷所有 json 元素
以下是eleasticsearch返回的json資料:{"took" : 12,"timed_out" : false,"_shards" ...
- [转]FastJSON通过SerializeFilter定制序列化
原文地址:https://github.com/alibaba/fastjson/wiki/SerializeFilter 简介 SerializeFilter是通过编程扩展的方式定制序列化.fast ...
- Java字符串面试(二)
先看下面2个程序 public static void main(String[] args) { String a = "a1"; String b = "a" ...
- RunLoop的深入了解
RunLoop 是 iOS 和 OS X 开发中非常基础的一个概念,这篇文章将从 CFRunLoop 的源码入手,介绍 RunLoop 的概念以及底层实现原理.之后会介绍一下在 iOS 中,苹果是如何 ...