InDesignerMan Posted November 18, 2013 Share Posted November 18, 2013 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: Link to comment https://forums.phpfreaks.com/topic/284007-looping-through-pixels-of-an-image/ Share on other sites More sharing options...
Rifts Posted November 18, 2013 Share Posted November 18, 2013 editing Link to comment https://forums.phpfreaks.com/topic/284007-looping-through-pixels-of-an-image/#findComment-1458711 Share on other sites More sharing options...
InDesignerMan Posted November 18, 2013 Author Share Posted November 18, 2013 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 ) { }; }; Link to comment https://forums.phpfreaks.com/topic/284007-looping-through-pixels-of-an-image/#findComment-1458712 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.