How to form String Using pixel Array and read all characters value of array

谁说胖子不能爱 提交于 2019-12-11 04:18:12

问题


I am Creating a binary image from processing ide. i want to use pixel array as a string . when i convert this pixel array to string i can't read String characters. every time i get an error. array index of bound. please help to out of this problem

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

                 String s = str(i);

                int c = s.charAt(1);

               print(c);
           }
        }

when i run this code in processing software i get an error in console that String Index out of Bound ..

please tell me what i do.


回答1:


Try with s.charAt(0): string indices are zero-based.



来源:https://stackoverflow.com/questions/56752110/how-to-form-string-using-pixel-array-and-read-all-characters-value-of-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!