如何使用 Quartz 在现有图像之上绘制来创建新图像?
我有一个 uiimageview 视图,我通过相机分配这个 uiimageview 图像..现在我想在图像上做一些绘图....使用 coregraphics.我想做这样的事情...通过触摸和画线选择一个区域线连接诸如圆形或任何形状之类的东西..我想将该特定区域更改为其他东西,例如更改那里的颜色。将其变成灰度..到目前为止我能够画线...这是线的图像在 uiimage 视图上绘制...
但我无法弄清楚如何在 imageview 的图像上绘制..意味着如何修改 imageview 的图像???
我也想在单击“清除”按钮或“撤消”之类的按钮时恢复图像。有人知道如何实现此目的吗?
单击裁剪按钮时如何
创建一个矩形,将矩形移动到屏幕上的任何位置...然后按下按钮裁剪图像...然后保存裁剪后的图像..
i have a view with uiimageview i assign this uiimageview image by camera..now i want to do some drawing onto image....using coregraphics.i want to do something like this... select an area by touching and drawing line when line joins something like circle or any shape..i want to change that particular area in to something else for example change color there.turn that into grayscale.. till now i am able to draw line...here is an image of line drawn over a uiimage view...
but i am unable to figure it out how do i draw at imageview's image..mean how to modify imageview's image???
also i want to restore image when click on clear button or something like undo..does someone knows how to achieve this?
and
how do i create a rectangle when click on crop button move the rectangle any where on the screen...and then push the button to crop the image...and then save cropped image..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
步骤如下:
下面是一个方法,它获取一个图像,在其上绘制一些内容,然后返回一个包含修改内容的新 UIImage:
要恢复到旧图像,只需保留对其的引用即可。
裁剪问题与上述内容无关,您应该为此创建一个新问题。
These are the steps:
Here's a method that takes an image, draws something on top of it and returns a new UIImage with modified contents:
To restore to old image, just keep a reference to it.
The cropping thing is not related to the above and you should create a new question for that.
更简单的解决方案是
A lot easier solution would be
看看Quartz 2D 概述,了解有关在 iPhone 上使用 Quartz 2D 的信息。
Take a look at Overview of Quartz 2D for information on using Quartz 2D on iPhone.