如何将由CGContextRef表示的位图图像保存到iPhone';什么是硬盘?
我有一个用Quartz2D拼凑起来的小草图程序,但我对iOS平台非常陌生,我很难弄清楚如何允许用户保存草图。我有一个包含草图的CGContextRef,如何保存它以便以后检索?保存后,如何检索如何将由CGContextRef表示的位图图像保存到iPhone';什么是硬盘?,iphone,ipad,core-graphics,quartz-graphics,Iphone,Ipad,Core Graphics,Quartz Graphics,我有一个用Quartz2D拼凑起来的小草图程序,但我对iOS平台非常陌生,我很难弄清楚如何允许用户保存草图。我有一个包含草图的CGContextRef,如何保存它以便以后检索?保存后,如何检索 非常感谢您的帮助!我现在将继续阅读这篇文章…有不同类型的CGContext。您很可能具有基于屏幕的上下文,但要创建位图或pdf文件,您需要bitmapContext或pdfContext 看。应感兴趣的职能包括: UIGraphicsBeginImageContext() UIGraphicsGetIm
非常感谢您的帮助!我现在将继续阅读这篇文章…有不同类型的CGContext。您很可能具有基于屏幕的上下文,但要创建位图或pdf文件,您需要bitmapContext或pdfContext 看。应感兴趣的职能包括:
UIGraphicsBeginImageContext()
UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageJPEGRepresentation()
UIImageWriteToSavedPhotosAlbum()
UIGraphicsBeginPDFContextToFile()
UIGraphicsEndPDFContext()
UIGraphicsBeginImageContext()
UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageJPEGRepresentation()
UIImageWriteToSavedPhotosAlbum()
UIGraphicsBeginPDFContextToFile()
UIGraphicsEndPDFContext()
- 有不同类型的CGContext。您很可能具有基于屏幕的上下文,但要创建位图或pdf文件,您需要bitmapContext或pdfContext
看。应感兴趣的职能包括:
- 我是这样做的
拯救
CGImageRef imageRef = CGBitmapContextCreateImage(bitmapContext);
UIImage* image = [[UIImage alloc] initWithCGImage:imageRef];
NSData* imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:filePath atomically:YES];
收回
UIImage* image = [UIImage imageWithContentsOfFile:filePath];
CGImageRef imageRef = [image CGImage];
我是这样做的
拯救
CGImageRef imageRef = CGBitmapContextCreateImage(bitmapContext);
UIImage* image = [[UIImage alloc] initWithCGImage:imageRef];
NSData* imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:filePath atomically:YES];
收回
UIImage* image = [UIImage imageWithContentsOfFile:filePath];
CGImageRef imageRef = [image CGImage];
我没有包括发布声明,但它们在那里。我没有包括发布声明,但它们在那里。