將GLPaint的PaintView與底圖一起存成image
在xib檔中,有一個drawview,放在這個drawview下方再加上一個UIimageView,並把他的名字定為backgroundView。接下來把這個View設定IBOutlet到AppController上。
接下來我們可以設定一個save的funcation。
-(void)saveImage{//使用這個方法就可以把圖片全部合併起來,並寫入到Album裡面了。
UIImageWriteToSavedPhotosAlbum([self imageRepresentationForBackground], self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
-(UIImage*) imageRepresentationForBackground
{
UIImage* blendedImage=nil;
UIImageView* imageView = [[UIImageView alloc] initWithFrame:backgroundView.bounds];
imageView.image= backgroundView.image;
imageView.contentMode=backgroundView.contentMode;
UIImageView* subView = [[UIImageView alloc] initWithImage:[drawingView imageRepresentation]];
[imageView addSubview:subView];
UIGraphicsBeginImageContext(imageView.frame.size);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[subView release];
[imageView release];
return blendedImage;
}
留言
張貼留言