Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why are you using a timer at all? Why not just have a double for loop in your function that loops over all possible x- and y-coordinates in the image? Surely that would be waaaay faster than only checking at most 100 pixels per second. You would want to have the x (width) coordinates in the outer loop and the y (height) coordinates in the inner loop so that you are effectively scanning one column of pixels at a time from left to right, since you are trying to find the leftmost black pixel.</p> <p>Also, are you sure that each pixel in your image has a 4-byte (Uint32) representation? A standard bitmap would have 3 bytes per pixel. To check if a pixel is close to black, you would just examine each byte in the pixel separately and make sure they are all less than some threshold.</p> <p>EDIT: OK, since you are using UIGetScreenImage, I'm going to assume that it is 4-bytes per pixel.</p> <pre><code>const UInt8 *pixels = CFDataGetBytePtr(imageData); UInt8 blackThreshold = 10; // or some value close to 0 int bytesPerPixel = 4; for(int x = 0; x &lt; width1; x++) { for(int y = 0; y &lt; height1; y++) { int pixelStartIndex = (x + (y * width1)) * bytesPerPixel; UInt8 alphaVal = pixels[pixelStartIndex]; // can probably ignore this value UInt8 redVal = pixels[pixelStartIndex + 1]; UInt8 greenVal = pixels[pixelStartIndex + 2]; UInt8 blueVal = pixels[pixelStartIndex + 3]; if(redVal &lt; blackThreshold &amp;&amp; blueVal &lt; blackThreshold &amp;&amp; greenVal &lt; blackThreshold) { //This pixel is close to black...do something with it } } } </code></pre> <p>If it turns out that bytesPerPixel is 3, then change that value accordingly, remove the alphaVal from the for loop, and subtract 1 from the indices of the red, green, and blue values.</p> <p>Also, my current understanding is that UIGetScreenImage is considered a private function that Apple may or may not reject you for using.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload