问题
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