iPhone 片断代码:截取屏幕保存图像
2010-04-11 16:27
281 查看
References
http://iphoneincubator.com/blog/tag/uigraphicsbeginimagecontextSource codes:
UIGraphicsBeginImageContext(imageView.frame.size);[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
NOTES:
1. UIGraphicsBeginImageContextCreates a bitmap-based graphics context and makes it the current context.
void UIGraphicsBeginImageContext ( CGSize size );
Parameters
size
The size of the new bitmap context. This represents the size of the image returned by the
UIGraphicsGetImageFromCurrentImageContextfunction.
Discussion
You use this function to configure the drawing environment for rendering into a bitmap. This drawing environment uses the premultiplied RGBA format to store the resulting bitmap data. The environment also uses the default coordinate system for UIKit views, where the origin is in the upper-left corner and the positive axes extend down and to the right of the origin. The drawing environment is pushed onto the graphics context stack immediately.
While the context created by this function is the current context, you can call the
UIGraphicsGetImageFromCurrentImageContextfunction to retrieve an image object based on the current contents of the context. When you are done modifying the context, you must call the
UIGraphicsEndImageContextfunction to clean up the bitmap drawing environment and remove the graphics context from the top of the context stack. You should not use the
UIGraphicsPopContextfunction to remove this type of context from the stack.
In most other respects, the graphics context created by this function behaves like any other graphics context. You can change the context by pushing and popping other graphics contexts. You can also get the bitmap context using the
UIGraphicsGetCurrentContextfunction.
2. Fill rect
[[UIColor redColor] set];
UIRectFill(CGRectMake(10,10, 200, 100));
3. Draw Text
NSString* greeting = @"Tom, how are you now ";
[greeting drawAtPoint:CGPointMake(205, 0) withFont:[UIFont fontWithName:@"Helvetica" size:36.0]];
相关文章推荐
- Windows Phone 7 截取当前屏幕保存图像的代码 推荐
- Windows Phone 7 截取当前屏幕保存图像的代码
- Windows Phone 7 截取当前屏幕保存图像的代码
- C# 截取屏幕图像并保存
- 在RFT中如何截取屏幕图像并保存到文件中?
- Android实现截取当前屏幕图像并保存至SDCard特定目录下
- uwp开发:截取当前屏幕中需要的图像并保存至应用内存储
- iOS中截取当前屏幕,并保存图片的代码例子
- iOS中截取当前屏幕,并保存图片的代码例子
- C# 图像处理(一)(图像缩放、屏幕截取、图像合并、保存图像)
- c++截取屏幕图片并保存(函数代码实现)
- c++截取屏幕图片并保存(函数代码实现)
- 截取手机屏幕中某个View的图像,并以图片形式保存到本地相册
- c++截取屏幕图片并保存(函数代码实现)
- jquery+.net实现类似开心网图像缩放截取功能(附代码下载)
- iphone post image片断代码
- 获取和保存当前屏幕的截图 实现的C++代码如下
- AWT 截取屏幕图像
- 截取控件和屏幕图片并保存
- opencv2 使用鼠标绘制矩形并截取和保存矩形区域图像