Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Looping through pixels of an image

$
0
0

Hi all,

 

I would like to loop through a rows and columns, like looping through pixels in a image, square by square, block  by block, this is my initial code and it works fine:

imagePixels = picture.getPixels();

for( y = 0; y < height ; y ++ ) 

{

    for ( x = 0; x < width; x ++ )
   {

      // Reads the image row by row, from top to bottom

   }

}

WHAT I NEED HELP WITH?

 

I can read an image row by row, starting from top to bottom as you can see from the loop above, however how would I go about Selected 4 pixels at a time? Like loop through it by chunks, 4 pixels at a time...

 

example:

xlhsf7.png
 


Viewing all articles
Browse latest Browse all 13200

Trending Articles