如何使用像素数组形成字符串并读取数组的所有字符值 [英] How to form String Using pixel Array and read all characters value of array

查看:104
本文介绍了如何使用像素数组形成字符串并读取数组的所有字符值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据处理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.

这篇关于如何使用像素数组形成字符串并读取数组的所有字符值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆