- 浏览: 396424 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (325)
- 神经网络 (1)
- javascript (11)
- 数据结构 (2)
- 计算机图形学 (11)
- 模式识别 (1)
- 前端开发 (14)
- 机器学习 (11)
- ios开发 (50)
- Python (9)
- HTML5 (4)
- 计算机视觉 (9)
- 数字图像处理 (7)
- 架构设计 (19)
- 数据库设计 (9)
- 算法设计 (59)
- Java (37)
- 其他 (3)
- 游戏开发 (5)
- c++ (17)
- Linux (3)
- TCP/IP (2)
- Flex (41)
- 健康 (6)
- AI (2)
- 工具 (1)
- 数据挖掘 (1)
- 性能优化 (6)
- 综合 (2)
- 网络通信 (12)
- Android (2)
- UML (3)
- 软件设计 (11)
- 编程经验 (7)
- J2EE (1)
- 多媒体技术 (3)
- 数学 (7)
- php (4)
- 设计 (1)
- CS (2)
- 计算机理论 (1)
- 信息安全 (1)
最新评论
-
ahead_zhan:
good good good
flex3控件_ModuleLoader -
lonerzf:
好样的。非常感谢楼主
OpenCV视频教程整理 -
lonerzf:
好样的。谢谢~
OpenCV视频教程整理 -
coding1688:
博主说的不错,我在实现瀑布流布局时也用的masonry插件,有 ...
Javascript 瀑布流式布局及其动态效果的实现 -
snowolf:
除非玩游戏,不然没啥win的事情,或者用win的银行客户端,通 ...
macbook安装操作系统的机理分析
UIView 转 UIImage 方法如下(关键是自适配分辨率):
- (UIImage*)lineImage:(UIColor *)color lineWidth:(float)width lineType:(int)type
{
self.lineColor = color;
lineWidth = width;
lineType = type;
//opaque:NO 不透明
UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 1.0);
//渲染自身
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *uiImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// [UIImagePNGRepresentation(uiImage) writeToFile:@"/users/test/desktop/a.png" atomically:YES];
return uiImage;
}
UIGraphicsBeginImageContextWithOptions
Creates a bitmap-based graphics context with the specified options.
void UIGraphicsBeginImageContextWithOptions(
CGSize size,
BOOL opaque,
CGFloat scale
);
Parameters
The size (measured in points) of the new bitmap context. This represents the size of the image returned by the UIGraphicsGetImageFromCurrentImageContext
function. To get the size of the bitmap in pixels, you must multiply the width and height values by the value in the scale parameter.
A Boolean flag indicating whether the bitmap is opaque. If you know the bitmap is fully opaque, you can specify YES
for this parameter to optimize the bitmap storage. Specifying NO
means that the bitmap must include an alpha channel to handle any partially transparent pixels.
The scale factor to apply to the bitmap. If you specify a value of 0.0
, the scale factor is set to the scale factor of the device’s main screen.
Updating Your Custom Drawing Code
When you do any custom drawing in your application, most of the time you should not need to care about the resolution of the underlying screen. The native drawing technologies automatically ensure that the coordinates you specify in the logical coordinate space map correctly to pixels on the underlying screen. Sometimes, however, you might need to know what the current scale factor is in order to render your content correctly. For those situations, UIKit, Core Animation, and other system frameworks provide the help you need to do your drawing correctly.
Creating High-Resolution Bitmap Images Programmatically If you currently use the UIGraphicsBeginImageContext function to create bitmaps, you may want to adjust your code to take scale factors into account. The UIGraphicsBeginImageContext function always creates images with a scale factor of 1.0. If the underlying device has a high-resolution screen, an image created with this function might not appear as smooth when rendered. To create an image with a scale factor other than 1.0, use the UIGraphicsBeginImageContextWithOptions instead. The process for using this function is the same as for the UIGraphicsBeginImageContext function:
- Call UIGraphicsBeginImageContextWithOptions to create a bitmap context (with the appropriate scale factor) and push it on the graphics stack.
- Use UIKit or Core Graphics routines to draw the content of the image.
- Call UIGraphicsGetImageFromCurrentImageContext to get the bitmap’s contents.
- Call UIGraphicsEndImageContext to pop the context from the stack.
For example, the following code snippet creates a bitmap that is 200 x 200 pixels. (The number of pixels is determined by multiplying the size of the image by the scale factor.)
UIGraphicsBeginImageContextWithOptions(CGSizeMake(100.0,100.0), NO, 2.0);
我感觉,这里写成:
UIGraphicsBeginImageContextWithOptions(CGSizeMake(100.0,100.0), NO, 0.0); 会更合适吧
发表评论
-
IVEngine —— Objective-C的Spring
2013-12-15 20:35 0背景: 只要是Java程序员,相信都听说 ... -
XCode环境变量及路径设置
2013-11-17 16:05 1730转自:http://blog.csdn.net/freedo ... -
OVGap — 沟通 Objective-C 与 Javascript
2013-11-14 15:14 774Github 地址: https://github.com ... -
IOS开发常用命令
2013-10-11 10:41 600统计代码行数 打开terminal, cd到项目根目 ... -
提高在Xcode上的工作效率
2013-08-31 11:05 1055转自:http://liuminqian.github.io ... -
把ipa包上传到AppStore
2013-08-26 21:46 892转自:http://doc.appcan.cn/dev_io ... -
iPhone应用程序中App目录结构
2013-08-26 17:30 930转自:http://blog.csdn.net/justin ... -
iOS运行回路(RunLoop)总结
2013-08-05 13:37 717转自:http://www.cocoachina.com/i ... -
Simple iPhone Keychain Access
2013-08-04 15:54 702转自:http://useyourloaf.com/b ... -
IOS媒体层
2013-07-28 15:18 805转自:http://wd397.blog.163.com/b ... -
nginx上搭建HLS流媒体服务器
2013-07-28 13:31 1349转自:http://blog.csdn.net/ ... -
Compile ffmpeg for iOS 6, support Simulator & armv7 & armv7s
2013-07-23 17:03 771转自:http://witcheryne.iteye.co ... -
UITableView 修改编辑模式下的切图
2013-07-14 21:03 1124把以下代码放在点解 “编辑” 按钮时触发的方法中。 ... -
iOS平台UDID方案比较
2013-07-09 20:27 1478转自:http://www.cocoachina.com/b ... -
25 Free iOS Design Resources
2013-05-12 19:08 518Some great designers around th ... -
谈谈iOS Animation
2013-05-07 09:39 573转自:http://geeklu.com/2012/09/a ... -
IOS文件系统的管理
2013-05-06 17:11 591转自:http://blog.csdn.net/zhuzhi ... -
iOS应用的本地缓存机制设计
2013-05-06 16:18 638参考:http://www.cnblogs.com/peng ... -
iOS并发编程指南(3)
2013-04-28 14:37 710转自:http://mobile.51cto.com/iph ... -
iOS运行回路(RunLoop)总结
2013-04-27 23:24 647转自:http://www.cocoachina.com/i ...
相关推荐
给 UIView 或 UIImage 高性能添加圆角,生成渐变色图片等
简单的把UIView转化为UIImage,大家可以看下。
作者remirobert,代码TextDrawer。 介绍:TextDrawer是一个UIView,允许您在UIView或UIImage上添加带有手势的文本。
高性能和轻量级的UIView,UIImage,UIImageView,UIlabel,UIButton等。 特征 SwiftyView GPU渲染图像和颜色 SwiftyColor —来自十六进制的颜色,来自UIColor的colorRGBA值,来自图像的颜色 用于通货膨胀/缩放/...
用法ParaMangar 有两个用途:它可以用于生成静态 PNG 文件作为动画 UIImage 加载,或者它可以在运行时制作动态动画 UIImage。生成静态图像文件您可以通过克隆此存储库并打开ParaMangar.xcodeproj来开始制作静态图像...
KTOneFingerRotationGestureRecognizer 实现了自定义的 UIGestureRecognizer 用于实现单手指旋转操作,同时会跟踪手指的移动。
UIImage Extension //UIImage扩展 NSString Extension //字符串扩展 UITabBar Badge //TabBar小红点扩展 Asset AssetHelper //相册 UploadImages UploadImageManager //图片上传 Download...
uiView 动画翻转的效果,显示前后两个视图替换显示
SwiftyUI高性能(100%)和轻量级(每个UI一个类)UIView,UIImage,UIImageView,UIlabel,UIButton等
可旋转Swift协议扩展,可将任何UIView Companion项目旋转到此博客文章: : ## Rotatable:可以旋转任何UIView的Swift协议扩展在StackOverflow上经常被问到的问题之一是“如何旋转UILabel / UIButton / UISlider等”...
包含了UIView UILabel UIImageView UIImage的常见用法,UIButton启动另一个界面的方法,关闭一个界面的方法。
UIView 动画 UIView动画
ios中关于uiview
UIView-Positioning, 在UIView对象中,基于简单属性的框架属性设置 uiview定位收费 UIView Positioning 是一个快速扩展,它提供简单的shorthand 方法,以方便的方式定义任何UIView对象的框架属性( 宽度,高度,x,y ...
SwiftUI功能使用具有的协议来更新UIView属性。 您可以阅读有关更多信息。 例子 直接在SwiftUI中使用UIKit视图: import SwiftUI import SwiftUIKitView struct SwiftUIwithUIKitView : View { var body: some ...
UIView AutoLayout ,UIView AutoLayout 是 UIView 的分类,实现了自动布局限制的简单接口。 T...
详细讲解UIView的生命循环周期,对开发者有更好的启发作用,深层次了解程序运行的流程。
UIView+Extension 对view的一个扩展
1、将UIView 保存为图片,按照给定的scale 2、stackoverflow参照 3、保存的图片为依据scale,亲测
+ (UIView *_Nullable)az_gradientViewWithColors:(NSArray*> *_Nullable)colors locations:(NSArray*> *_Nullable)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint; - (void)az_...