From: Rob Biedenharn Date: 2009-12-08T04:04:36+09:00 Subject: Re: Reading Images On Dec 7, 2009, at 1:56 PM, Alexandro Kez wrote: > Fleck, thanks for this really good answer, but could you tell then > what > other data format may I use to avoid such parsings? I don't want to > use > anything extra. Dunno about RMagick, but I've seen some rubyrames > example, where it's also done easy, but I wanna make it with ass few > external libs as possible, that's the idea - I wanna see if ruby "da > solo" is enough to coupe with such problems. Before you continue, perhaps you need to read from the OpenGL FAQ: 21.110 How can I turn my files, such as GIF, JPG, BMP, etc. into a texture map? http://www.opengl.org/resources/faq/technical/texture.htm#text0100 and the section that it references, too: 24.050 How can I save my OpenGL rendering as an image file, such as GIF, TIF, JPG, BMP, etc.? How can I read these image files and use them as texture maps? http://www.opengl.org/resources/faq/technical/miscellaneous.htm#misc0050 So while you could use "ruby da solo", it's unlikely that you really want to. -Rob > Fleck Jean-Julien wrote: > >> The image.txt file looks like >> >> # ImageMagick pixel enumeration: 712,490,255,RGB >> 0,0: (226,188,115) #E2BC73 rgb(226,188,115) >> 1,0: (227,189,116) #E3BD74 rgb(227,189,116) >> 2,0: (226,188,115) #E2BC73 rgb(226,188,115) >> ... >> 709,489: (224,207,125) #E0CF7D rgb(224,207,125) >> 710,489: (211,203,120) #D3CB78 rgb(211,203,120) >> 711,489: (134,129, 45) #86812D rgb(134,129,45) >> >> and its really easy to get the size (712x490) and the pixels colors >> reading the file directly throught >> >> File.open(txt) do |f| >> f.readlines.each do |line| >> # action on each line using regexp to get the colors >> end >> end >> >> Cheers, > -- > Posted via http://www.ruby-forum.com/. > Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com +1 513-295-4739 Skype: rob.biedenharn