How to combine drawn pixels in a UIView with the image in a UIImageView and save it as a new image?

泪湿孤枕 提交于 2019-12-25 05:12:32

问题


I am wondering how to combine drawn pixels in a UIView with the image in a UIImageView and save it as a new image? I have no clue how to go about this.

If anyone could point me in the right direction, I would love it.

Thank you!


回答1:


Check out Quartz 2D. Specifically, CGContextDrawImage() can be used to load an image, draw whatever you want on this context, and then you can CGBitmapContextCreateImage() to create a CGImageRef from which you can create an image with UIImage's imageWithCGImage. Finally, you use UIImagePngRepresentation() or UIImageJPEGRepresentation() to get a NSData that you can then use writeToFile with.



来源:https://stackoverflow.com/questions/10126729/how-to-combine-drawn-pixels-in-a-uiview-with-the-image-in-a-uiimageview-and-save

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!