From: Kamaljeet Saini Date: 2009-01-23T01:34:55+09:00 Subject: Re: Converting binary image file to bmp file using RMagick2.0 The above posting code worked fine for 704/480 binary to image file but for the attached file the same code is not working. Its 800/480 binary file. Possible to advice please. Im try to use the following code. require 'rmagick' file_name = "C:/image2.text" # the binary file image_file_name = "C:/image2.bmp" # the expected file to be generated image = Magick::Image.new(800, 480) file = File.open(file_name,"rb").read one = [] two = [] three = [] file.unpack('S*').each { |x| three << (x & 0x1F) * 8 #puts "Three: #{three}" two << ((x >> 5) & 0x1F) * 8 #puts "Two: #{two}" one << ((x >> 10) & 0x1F) * 8 #puts "One: #{one}" } bufferscreen_height=480 bufferscreen_width=800 k=0 for i in 0...bufferscreen_height for j in 0...bufferscreen_width q=Magick::Pixel.new(one[k],two[k],three[k],0) image.pixel_color(j,i,q) k += 1 end end image.write(image_file_name) Attachments: http://www.ruby-forum.com/attachment/3194/image2.text -- Posted via http://www.ruby-forum.com/.