From: Kamaljeet Saini Date: 2009-02-05T06:05:22+09:00 Subject: Re: Converting binary image file to bmp file using RMagick2.0 Hi, The attached binary file is not displays image correctly and looks like pixel shift is required. If i can get help on this please. require 'rmagick' file_name = "C:/Hubimage1.txt" # the binary file image_file_name = "C:/Hubimage1.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| one << (((x & 0xF800) >> 11) << 3) two << (((x & 0x7E0) >> 5) << 2) three << ((x &0x1F)<< 3) } 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/3260/Hubimage1.zip -- Posted via http://www.ruby-forum.com/.