pjb
3/22/2009 10:49:00 PM
jeljer te Wies <jeljer@me.com> writes:
> Eric Jacoboni wrote:
>> jeljer te Wies <jeljer@me.com> writes:
>>
>>
>>> Here is some sample code i made but doesn't work:
>>>
>>> f = File.new("PNG.png")
>>> image = f.readlines
>>>
>>> puts image.to_hex
>>
>>
>> Without knowing exactly what you want to do...
>>
>> 1) f.readlines gives an *Array* of strings
>> 2) to_hex doesn't exist in Ruby. You probably want sprintf "%X"
>
> well to explain why I want to do this! :P ..
> here is my ehm... job discription:
>
> The pixels in the above image are numbered 0..99 for the first row,
> 100..199 for the second row etc. White pixels represent ascii codes. The
> ascii code for a particular white pixel is equal to the offset from the
> last white pixel. For example, the first white pixel at location 65
> would represent ascii code 65 ('A'), the next at location 131 would
> represent ascii code (131 - 65) = 66 ('B') and so on
>
> The text contained in the image is the answer encoded in Morse, where "a
> test" would be encoded as ".- / - . ... -"
>
> This is what I have to do.. that's why I need some kind of hex codes in
> a long string or array so I can see what pixels are white and which one
> are black
And what's the relationship with lines and hex?
You want to write methods named Image.width, Image.height,
Image.pixelAt(x,y), Pixel.isWhite?, Pixel.isBlack?, things like that.
--
__Pascal Bourguignon__