Class: TiRLE
- Inherits:
-
Ti99File
- Object
- NativeFileType
- Ti99File
- TiRLE
- Defined in:
- lib/native_file_types/ti99/TiRLE.rb
Constant Summary collapse
Instance Attribute Summary
Attributes inherited from NativeFileType
#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data
Instance Method Summary collapse
Methods inherited from Ti99File
file_system_file_types, #type_description
Methods inherited from NativeFileType
#<=>, #==, all_native_file_types, best_fit, code_for_tests, compatability_score, #data_without_header, file_type_matches?, #full_filename, #header_length, #initialize, is_valid_file_if, #load_address, load_address, matching_score, native_file_types_possible_on_file_system, non_matching_score, #to_hex_dump, #to_info_dump, #type_description
Methods included from SubclassTracking
Constructor Details
This class inherits a constructor from NativeFileType
Instance Method Details
#picture_format ⇒ Object
62 63 64 |
# File 'lib/native_file_types/ti99/TiRLE.rb', line 62 def picture_format :png end |
#picture_height ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/native_file_types/ti99/TiRLE.rb', line 23 def picture_height case contents[2] when 0x48 then return 192 #H=High Resolution when 0x4D then return 96 #M=Medium Resolution end raise "invalid RLE graphic mode #{buffer[2].chr}" end |
#picture_width ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/native_file_types/ti99/TiRLE.rb', line 16 def picture_width case contents[2] when 0x48 then return 256 #H=High Resolution when 0x4D then return 128 #M=Medium Resolution end raise "invalid RLE graphic mode #{buffer[2].chr}" end |
#to_picture ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# 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 |