在 iPhone 上读取和编辑图像像素
好奇如何在 iPhone 上读取和编辑图片的像素。我最好使用带有颜色的点数组吗?
我想做的事情是……如果 CGPoint 与图片上的“棕色”点相交,则将半径中所有棕色像素的颜色设置为白色。更多问题还会出现,但这只是一个开始。
干杯
Curious about how to read and edit a picture's pixels on the iPhone. Am I better of using an array of points with colours?
I want to do things like.. if a CGPoint intersects with a "brown" spot on the picture, set the colour of all brown pixels in a radius to white. More questions to come, but this is a start.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用图片数据——二维像素数组,每个像素由一个 32 位整数表示。对于每个颜色分量(红色、绿色、蓝色和 alpga),都有一个 8 位值。 32 位整数内这些 8 位宽值的顺序随图像数据的格式而变化。关于这一切的苹果文档非常好。虽然有一些有吸引力的 Apple 东西使用 CGDataProviderCopyData 为您提供 UIImage 实际数据存储的指针,但实际上这可能会令人头痛,因为内部存储的格式从一个图像到下一个图像可能会有很大差异。在实践中,大多数进行图像处理的人似乎都使用这种方法:
The picture data is available to you as precisely that -- a two-dimensional array of pixels, each pixel being represented by a 32 bit integer. For each of the color components (red, green, blue, and alpga) there is an 8 bit value. The ordering of these 8-bit-wide values within the 32 bit integer varies with the format of the picture data. The apple doc about all this is really good. While there is some attractive Apple stuff using CGDataProviderCopyData to give you a pointer into the actual data storage of a UIImage, in practice this can be a headache, because the format of that internal storage can vary widely from one image to the next. In practice, most people doing image processing seem to use this approach: