# How to make grid of image pixels in nested loop

**URL:** <https://discourse.processing.org/t/how-to-make-grid-of-image-pixels-in-nested-loop/12356>\
**Category:** Coding Questions\
**Created:** [June 28, 2019, 11:35am UTC](https://discourse.processing.org/t/how-to-make-grid-of-image-pixels-in-nested-loop/12356 "2019-06-28T11:35:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_nish](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/the_nish/32/5634_2.png) [@The\_nish](https://discourse.processing.org/u/The_nish)\
**Post date:** [June 28, 2019, 11:35am UTC](https://discourse.processing.org/t/how-to-make-grid-of-image-pixels-in-nested-loop/12356/1 "2019-06-28T11:35:03Z")

</div>

i have image pixel length from 0 to 10000 . i want to make a grid of 100\*100 in nested loop.  
please tell me how can i do that…

```auto
  for (int y=0; y<img.height; y++)
  {
    for (int x=0; x<img.width; x++)

    {
      int i= x+y*width;
     
      
     if ((i+1)%100 == 1) {
        
        print("\n");
       
      }
}
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 28, 2019, 12:55pm UTC](https://discourse.processing.org/t/how-to-make-grid-of-image-pixels-in-nested-loop/12356/2 "2019-06-28T12:55:57Z")

</div>

You can use resize on your image to make it small

Then do the for loop

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [June 28, 2019, 7:57pm UTC](https://discourse.processing.org/t/how-to-make-grid-of-image-pixels-in-nested-loop/12356/3 "2019-06-28T19:57:32Z")

</div>

Hey there the\_nish,

Have you gone through the [Images and Pixels](https://processing.org/tutorials/pixels/) tutorial yet? About halfway, at the example called _Displaying the pixels of an image_, they show how the stored pixels (your 0 to 10.000 situation) gets converted to an image (the 100x100 grid you want to make).

Does that help?
