I was thinking about parsing through the source text to get the pixel data and then put them into an array of integers. How would I elegantly parse this data and pull out the pixel information without making it too expensive? Also, is this the most effective way of processing an image file with this format and returning it as an image object?
This is the structure of the plain text:
name
n m
px0,0 px0,1 … px0,m
px1,0 px1,1 … px1,m
pxn,0 pxn,1 … pxn,m
Example:
TestName
5 5
55, 6, 65, 79, 99
10, 25, 0, 45, 66
88, 19, 188, 76, 50
Parsing will take O(nm) anyway, since you need to parse all “pixels”. Concerning elegance – you might probably look at Google Guava classes:
Returning an “image” can be a good idea for compressing the data, but only if it’s a lossless format (e.g. PNG).