Skip to content
Advertisement

Script freezes after completing a ‘while’ loop in a ‘while’ loop (oops)

How can get the RGB values of every pixel in an image and after it gets all the values of the first row?

Script:

JavaScript

Advertisement

Answer

The way you initialize your x and y values is the problem. X should be initialized back to zero immediately before the second while loop, so that the count starts again for the width of the next row.

Something like:

JavaScript

Your loop freezes, because at the end of the first row, x=width and you forget to reset it back to zero for the second iteration of the first while loop.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement