在图片上绘图并保存到手机,要用到什么技术 主要是core graphic 技术 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你推荐两个类似的例子吧:http://code4app.com/ios/DrawReport/528c2f69cb7e848c168b4ba7http://code4app.com/ios/PIImageDoodler/5332e7a3933bf06f088b4eb2 谢谢zhanglei5415,我看了这两个demo了,和我的需求不符合啊,我是想在图片上画线和圆圈,然后保存修改后的图片到手机相册。现在看到找到的都是只保存了那些画出来的线和圆圈,却没有保存原图再厚颜请教下,能指点下吗。。 不太有思路,该怎么办呢,我看了很多demo,画线了之后,通过UIGraphicsGetImageFromCurrentImageContext()获取到图片,但是这图片只是画出来的线啊,我是希望在一张大图上画线,然后保存这张画了线的图片,请问有什么方法可以做到吗? 可以将两张图片合并得到合并后的图片 UIGraphicsBeginImageContext(oneImg.size); [oneImg drawInRect:CGRectMake(0, 0, oneImg.size.width, oneImg.size.height)]; [twoImg drawInRect:CGRectMake(tlPos.x, tlPos.y, twoImg.size.width, twoImg.size.height)]; UIImage *resultImg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 在图片中涂鸦之后,可以获取当前屏幕像素(相当于截屏)。之后保存为图片到本地图片库。代码如下:截屏:-(UIImage *)getImageFromView:(UIImageView *)theView{ //重点在[UIScreen mainScreen].scale,保存图片不模糊 UIGraphicsBeginImageContextWithOptions(imageView_.bounds.size, YES, [UIScreen mainScreen].scale); [theView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image;}保存图片到设备的图片库中的方法:UIImageWriteToSavedPhotosAlbum- (void)saveImage{ UIImage *Image = [UIImage imageNamed:@"1.PNG"]; UIImageWriteToSavedPhotosAlbum(Image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);}- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{ NSString *msg = nil; if(error != NULL) { msg = @"保存图片失败"; } else { msg = @"保存图片成功"; } UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"保存图片结果提示" message:msg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show];} iOS 对象删除问题 html5的网站怎么打包到ipad啊 iphone开发,混合c++代码,CString,LPTSTR,LPCTSTR的类型怎么办? 求IOS开发优秀的入门书籍 求助一个数据存取的问题 UISwipeGestureRecognizer 实现侧滑菜单的问题 ios开发问题 iOS 旋转减速问题 ios状态栏和tabbar显示异常?有人碰到过嘛 菜鸟求教,如何让ScrollView填满整个屏幕? IOS从本地选取的视频怎么加滤镜和文字效果 请教一个关于nsstring和char之间转换的问题。
http://code4app.com/ios/DrawReport/528c2f69cb7e848c168b4ba7
http://code4app.com/ios/PIImageDoodler/5332e7a3933bf06f088b4eb2
UIGraphicsBeginImageContext(oneImg.size);
[oneImg drawInRect:CGRectMake(0, 0, oneImg.size.width, oneImg.size.height)];
[twoImg drawInRect:CGRectMake(tlPos.x, tlPos.y, twoImg.size.width, twoImg.size.height)];
UIImage *resultImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
-(UIImage *)getImageFromView:(UIImageView *)theView
{
//重点在[UIScreen mainScreen].scale,保存图片不模糊
UIGraphicsBeginImageContextWithOptions(imageView_.bounds.size, YES, [UIScreen mainScreen].scale);
[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}保存图片到设备的图片库中的方法:UIImageWriteToSavedPhotosAlbum- (void)saveImage
{
UIImage *Image = [UIImage imageNamed:@"1.PNG"];
UIImageWriteToSavedPhotosAlbum(Image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
NSString *msg = nil;
if(error != NULL)
{
msg = @"保存图片失败";
}
else
{
msg = @"保存图片成功";
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"保存图片结果提示" message:msg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
}