保存图片
来源:互联网 发布:领取q币软件 编辑:程序博客网 时间:2024/05/03 08:45
#pragma mark -
#pragma mark save image
- (void) saveImage {
if (m_imgSuccess.image != nil) {
//set the path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//name the file
//NSString *uniquePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"reckoningInfor.jpg"];
NSString *uniquePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"hym_test.jpg"];
//write to Documents
UIGraphicsBeginImageContext(m_mainView.frame.size);
/*
CGSize sizeContext;
sizeContext.width = 100;
sizeContext.height = 70;
UIGraphicsBeginImageContext(sizeContext);
*/
CGContextRef context = UIGraphicsGetCurrentContext();
[m_mainView.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
/*
CGRect ret=CGRectMake(0.0, 0.0, 90, 90);
CGContextClipToRect(context, ret);
CGRect bounds=CGContextGetClipBoundingBox(context);
UIImage *image = [[UIImage alloc] init];
CGContextDrawImage(context, self.bounds, image);
*/
BOOL rev = [UIImageJPEGRepresentation(image, 1)writeToFile:uniquePath atomically:YES];
//check the rev value , only use in test environment
if (rev) {
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Tip message"
message:@"save sucess!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
}
#pragma mark save image
- (void) saveImage {
if (m_imgSuccess.image != nil) {
//set the path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//name the file
//NSString *uniquePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"reckoningInfor.jpg"];
NSString *uniquePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"hym_test.jpg"];
//write to Documents
UIGraphicsBeginImageContext(m_mainView.frame.size);
/*
CGSize sizeContext;
sizeContext.width = 100;
sizeContext.height = 70;
UIGraphicsBeginImageContext(sizeContext);
*/
CGContextRef context = UIGraphicsGetCurrentContext();
[m_mainView.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
/*
CGRect ret=CGRectMake(0.0, 0.0, 90, 90);
CGContextClipToRect(context, ret);
CGRect bounds=CGContextGetClipBoundingBox(context);
UIImage *image = [[UIImage alloc] init];
CGContextDrawImage(context, self.bounds, image);
*/
BOOL rev = [UIImageJPEGRepresentation(image, 1)writeToFile:uniquePath atomically:YES];
//check the rev value , only use in test environment
if (rev) {
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Tip message"
message:@"save sucess!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
}
- 保存图片
- 保存图片
- 图片保存
- 保存图片
- 保存图片
- 保存图片
- 保存图片
- 图片保存
- 保存图片
- 图片保存
- 压缩图片,保存图片
- C# 远程保存图片 图片远程保存
- 数据库保存图片和文件保存图片
- firefox 图片保存 图片上传
- 图片处理 截图+保存图片
- opencv打开图片保存图片
- android 查看图片、保存图片
- 自动保存远程图片
- udev学习笔记
- LCA的Tarjan离线算法
- 基于SIM300的GPRS网络通讯
- 在linux中查看线程数的三种方法
- js 让集合只接收特定的类型的元素
- 保存图片
- java中不常见的关键字:strictfp,transient
- 循环小数
- 揭开Socket编程的面纱(转)
- 北京“银医一卡通”项目启动
- WinPE 安装 2003
- udev学习笔记
- C++ Vector 使用心得
- Web Testing: Complete guide on testing web applications