Module: ApplePrintShopMiniPix

Included in:
AppleDosPrintShopMiniPix, ProDosPrintShopMiniPix
Defined in:
lib/native_file_types/apple2/ApplePrintShopMiniPix.rb

Overview

Format is 88x52 pixels

Constant Summary collapse

APS_MINIPIX_FOREGROUND =
PNG::Color.new(0x01,0x01,0x01,0xFF)
APS_MINIPIX_BACKGROUND =
PNG::Color.new(0x80,0x80,0x80,0x80)

Instance Method Summary collapse

Instance Method Details

#picture_formatObject



47
48
49
# File 'lib/native_file_types/apple2/ApplePrintShopMiniPix.rb', line 47

def picture_format
  :png
end

#picture_heightObject



44
45
46
# File 'lib/native_file_types/apple2/ApplePrintShopMiniPix.rb', line 44

def picture_height
  52
end

#picture_widthObject



41
42
43
# File 'lib/native_file_types/apple2/ApplePrintShopMiniPix.rb', line 41

def picture_width
  88
end

#to_pictureObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/native_file_types/apple2/ApplePrintShopMiniPix.rb', line 17

def to_picture
  canvas = PNG::Canvas.new picture_width, picture_height, PNG::Color::Green
  buffer=data_without_header
  52.times do |y|
    row_data=buffer[y*11,11]
    x=0
    row_data.each_byte do |byte|
      8.times do |bit_offset|        
        bitmask=0b10000000>>bit_offset    
#        puts "y #{y} x #{x} byte #{"%08b" % byte} bit #{bit_offset} #{"%08b" % bitmask}"
        if ((byte & bitmask)==bitmask) then
          canvas[x, y]= APS_MINIPIX_FOREGROUND
        else
          canvas[x, y]= APS_MINIPIX_BACKGROUND
        end
        x+=1
      end
    end
  end
  png = PNG.new canvas
  result=png.raw_bytes
  result
end