How could we implement the code if I want to read a grayscale image file into two dimensional byte array? Since we don't always know the number of rows and columns binary file has beforehand, how can I read that into 2-D array? A grayscale image is single band image and each pixel has a value between 0 and 255. Lets say my binary file has 20 rows and 10 columns (that is it is made of a total of 200 pixels). But what if I have a file and I don't know the number of rows and columns in it?

I would appreciate if someone gives me the code to know the number of rows and columns of a binary file or image file before reading into byte array. Once we know these number of rows and columns, the rest should be no problem.

I am trying to read binary file into 2-D byte array because I am going to manipulate the array elements.

Any help is greatly appreciated.

9 Years
Discussion Span
Last Post by iamthwee
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.