Pixel to String length

i am converting my image pixel as a string and print of its length then i get output is given in example image.
what is wrong with it.


void function()
{
  for(int x=0; x<img.height;x++)
  {
       
    for(int y=0; y < img.width; y++)
    {
       int i = y+x*img.width;
        
         s = str(i);
     print(s.length());
          
 }          
   
  }
    
}

and please tell how to formatting it in 100*100 digit. without using “\n” or “\r” ;

int i = y * img.width + x;
1 Like

problem is remain same.

Hey there !

It a bit unclear what the problem is. Could you give a more in-depth example ?

if you actually want to print the string lengths in a 100x100 grid
in the console just build a string equivalent to a row of the image
then output it with println instead of print. it probably won’t line
up but you could pad the numbers (something like) you get to some length to give you
an even print out

void function()
{
  String s;  
  for(int x = 0; x < img.height;x++)
  {
	s = "";//this is terrible should use something like a string builder or whatever processing has
	for(int y = 0; y < img.width; y++)
    {
       s += y + x * img.width;
	}
	println(s.length());
  }   
}
1 Like