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
 

Edited by InDesignerMan
Link to comment
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 ) {
              
               
            };
        };
Edited by InDesignerMan
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.