# File lib/native_file_types/ti99/TiRLE.rb, line 33 def to_picture buffer=contents cols=picture_width rows=picture_height canvas = PNG::Canvas.new cols, rows, PNG::Color::Black p=3 colour_index=0 done=false bit_index=0 while !(buffer[p]).nil? if buffer[p]>=0x20 then #skip over any control characters run_length=(buffer[p]-0x20) run_length.times do x=bit_index % cols y=bit_index / cols break if y>=rows canvas[x, y]= RLE_COLOURS[colour_index] bit_index+=1 end colour_index=((colour_index+1)%2) end p+=1 end png = PNG.new canvas result=png.raw_bytes result end