How to get UIColor from UIImage on iPhone

I want to process my image point by point, but I do not know how to get the color of a point from an image. And how to move the pointer over a point?

+3
source share
2 answers

You cannot do this directly from UIImage, but you can display the image in a raster context with the memory buffer that you supply, and then check the memory directly. It sounds harder than it really is, but it can be harder than you wanted to hear.

If you have an Erica Sadun iPhone Cookbook for developers, you can clearly see it from page 54. I would recommend the book as a whole, so it’s worth it to get it if you don’t have one.

, , , , Sadun. pointInside float , int. , , , . , , , int - :


long startByte = ((int)point.y * (int)size.width) + (int)point.x) * 4;

, Sadun, , -, 8- , -. CGBitMapContextCreate (, 8 , InsideInside).

[] ( , , ):

+3

- , CreateARGBBitmapContext memset (bitmapData, 0, bitmapByteCount); malloc, - .

+1

Source: https://habr.com/ru/post/1703334/


All Articles