如何弄清楚“特定像素的颜色”。在图像? [英] How to figure out "Color of a specific pixel" in an image?
问题描述
我的图像位于图像视图中。我想在图像中找到特定像素的颜色(比如x = 10,y = 20)。工作代码真的可以帮助我。
I have an image which is inside an Image View. I want to find the color of a specific pixel (say x=10, y=20) inside the image. Working code would really help me out.
推荐答案
这在很大程度上取决于图像的类型:)
That depends very much on the type of image :)
如果您有字节数据,并且知道它是如何排列的,例如 PNG 使用 RGBA ,然后你就开始了。
If you have the byte data, and you know how it is arranged, for example PNG uses RGBA then you've got a leg up.
自由使用所有 CGImageFunctions 将成为您的向导。
Liberal use of all the CGImageFunctions like CGImageGetBitsPerComponent and CGImageGetColorSpace will be your guide.
要获取实际的字节数据, CGIm ageDestinationCreateWithData 创建一个写入Core Foundation可变数据对象的图像目标(NSMutableData * / CFMutableDataRef)
To get the actual byte data, CGImageDestinationCreateWithData Creates an image destination that writes to a Core Foundation mutable data object (NSMutableData* / CFMutableDataRef)
如果所有这些都是乱码,请从< a href =http://developer.apple.com/mac/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_data_mgr/dq_data_mgr.html#//apple_ref/doc/uid/TP30001066-CH216-BAJGAIEE =nofollow noreferrer> Quart2D编程指南。
If all of this is gibberish, start with the Quart2D Programming Guide.
这篇关于如何弄清楚“特定像素的颜色”。在图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!