如何使用像素数组形成字符串并读取数组的所有字符值

问题描述:

我正在根据处理IDE创建一个二进制映像. 我想使用像素数组作为字符串. 当我将此像素数组转换为字符串时,我无法读取字符串字符.每次我得到一个错误.绑定的数组索引. 请帮助解决这个问题

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

请告诉我我该怎么做.

尝试使用s.charAt(0):字符串索引从零开始.

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