$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'PatchedPNG' require 'ProDosFile' #Apple Print Shop "MiniPix" format # per http://groups.google.com.au/group/comp.sys.apple2.programmer/browse_frm/thread/414857c71d52b5d5/c7c883c10f648ca0 # Format is 88x52 pixels module ApplePrintShopMiniPix APS_MINIPIX_FOREGROUND=PNG::Color.new(0x01,0x01,0x01,0xFF) APS_MINIPIX_BACKGROUND=PNG::Color.new(0x80,0x80,0x80,0x80) 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 def picture_width 88 end def picture_height 52 end def picture_format :png end end class AppleDosPrintShopMiniPix