Class: AtariMicroPainterPic

Inherits:
NativeFileType show all
Defined in:
lib/native_file_types/atari800/AtariMicroPainterPic.rb

Instance Attribute Summary

Attributes inherited from NativeFileType

#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data

Class Method Summary collapse

Instance Method Summary collapse

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

extended

Constructor Details

This class inherits a constructor from NativeFileType

Class Method Details

.file_system_file_typesObject



26
27
28
29
30
# File 'lib/native_file_types/atari800/AtariMicroPainterPic.rb', line 26

def self.file_system_file_types
  {
    AtariDos=>:any
  }
end

Instance Method Details

#picture_formatObject



22
23
24
# File 'lib/native_file_types/atari800/AtariMicroPainterPic.rb', line 22

def picture_format
  :png
end

#picture_heightObject



19
20
21
# File 'lib/native_file_types/atari800/AtariMicroPainterPic.rb', line 19

def picture_height
	192
end

#picture_widthObject



16
17
18
# File 'lib/native_file_types/atari800/AtariMicroPainterPic.rb', line 16

def picture_width
	160
end

#to_pictureObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/native_file_types/atari800/AtariMicroPainterPic.rb', line 32

def to_picture
  canvas = PNG::Canvas.new picture_width, picture_height, PNG::Color::Black
  colours=[Atari800.palette[contents[0x1E00]],Atari800.palette[contents[0x1E01]],Atari800.palette[contents[0x1E02]],Atari800.palette[contents[0x1E03]]]
  picture_height.times do |row|
  	picture_width.times do |col|
  		byte_ptr=row*40+col/4
  		byte=contents[byte_ptr]
  		colour_number=case (col % 4 ) 
  			when  3 then byte % 4
  			when  2 then (byte>>2) % 4
  			when  1 then (byte>>4) % 4
  			when  0 then (byte>>6) % 4
  		end
  		
  		colour=colours[colour_number]
  		
  		canvas[col, row]= colour
  	end
  end
  png = PNG.new canvas
  result=png.raw_bytes
  result

end