Jump to content

Looping through pixels of an image


InDesignerMan

Recommended Posts

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
 

Link to comment
https://forums.phpfreaks.com/topic/284007-looping-through-pixels-of-an-image/
Share on other sites

so while you are editing there Rifts, I was thinking,

 

what if I did 

(x,y + 1), (x + 1, y +1), (x,y) and (x+1,y) ? 

while doing

 

 for ( int y=0 ; y<height ; y+=2 ) {
            for ( int x=0 ; x<width ; x+=2 ) {
              
               
            };
        };

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.