The summary of your requirements: You have a PNG that looks like an 
old-fashioned punched card, with dots in specific locations that you must decode.

The reason behind this requirement now becomes an object of curiosity! You will 
get the best answer if you confess what it is...

jeljer te Wies wrote:

> f = File.new("PNG.png")
> image = f.readlines
> 
> puts sprintf ("%X", image[2])

Your "fast reply" was just a Google hit for "PNG". Please always google before 
posting.

And read the cites! The third byte of a PNG file is _not_ the third pixel from 
the top! A PNG file is _probably_ a header with several variable-length extents 
of configurational data (how many colors, what dimensions, the author's name, 
etc.) followed by a _compressed_ block of data for the bit planes in the image.

Use ImageMagick's convert utility to convert your file to PNM format, to remove 
the compression...