From: pjb@... (Pascal J. Bourguignon) Date: 2009-03-23T08:07:05+09:00 Subject: Re: convert PNG to hex jeljer te Wies writes: > Pascal J. Bourguignon wrote: >> jeljer te Wies writes: >> >>>> >>> 100..199 for the second row etc. White pixels represent ascii codes. The >>> 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. > > now it is a task I would like to complete.. > The only thing I want to know is "Who many black pixels are between the > white pixels". > (I have uploaded the image) ... > > So what i want is: > 1) get the image in my program > 2) get each pixel and decide if it is white or black Well it's easy enough to do that with the methods I proposed above. Something like: def decode(image) i=0 lastWhite=0 bytes=[] (0..(image.height)).each {| y | (0..(image.width)).each {| x | if image.pixelAt(x,y).isWhite? then bytes.push(i-lastWhite) lastWhite=i end i=i+1 } } bytes end (That's the reason why I proposed those methods). Now you only have to implement them, doing the same: whish for methods that would make implement the method pixelAt(x,y) easy, and do it. Then further implement the missing methods. -- __Pascal Bourguignon__