$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'PatchedPNG' #generic class for a HI-RES picture class AppleHiResPic0) if (bit_set) then if (last_bit_set) then #adjacent pixels should both be white AppleHiResPic.set_pixel(canvas,x-1,y,HGR_WHITE) AppleHiResPic.set_pixel(canvas,x,y,HGR_WHITE) else if current_byte>=0x80 then pallete=[HGR_BLUE,HGR_ORANGE] else pallete=[HGR_VIOLET,HGR_GREEN] end this_pixel_colour=pallete[x%2] AppleHiResPic.set_pixel(canvas,x,y,this_pixel_colour) AppleHiResPic.set_pixel(canvas,x+1,y,this_pixel_colour) unless x>=HGR_COLS-1 end end last_bit_set=bit_set end end end png = PNG.new canvas result=png.raw_bytes result end def picture_width HGR_COLS end def picture_height HGR_ROWS end def picture_format :png end private def self.set_pixel(canvas,x,y,colour) canvas[x, y]= colour end end class AppleDosPic < AppleHiResPic def self.file_system_file_types { AppleDos=>0x04 } end def self.load_address(contents) contents[0]+contents[1]*256 end def header_length 4 end def unpacked_picture_bytes data_without_header end is_valid_file_if lambda { load_address=AppleBinary.load_address(contents) ((contents.length>=8184) && (contents.length<=9000) && ((load_address==0x2000) || load_address==0x4000)) } end class NADOLPic < AppleHiResPic def self.file_system_file_types { NADOLDos=>:any } end is_valid_file_if lambda { (contents.length==8192) } def unpacked_picture_bytes contents end end class PascalPic < AppleHiResPic def self.file_system_file_types { PascalDos=>0x07 } end def unpacked_picture_bytes contents end end class ProDosBinPic < AppleHiResPic def self.file_system_file_types { ProDos=>0x06 } end is_valid_file_if lambda { (aux_code==0x2000 || aux_code==0x4000) && ((contents.length>=8192) && (contents.length<=9000)) || (aux_code==0x2000 && contents.length==0x4000) } def unpacked_picture_bytes contents end def load_address aux_code end end # == Author # Jonno Downes (jonno@jamtronix.com) # # == Copyright # Copyright (c) 2008 Jonno Downes (jonno@jamtronix.com) # #Permission is hereby granted, free of charge, to any person obtaining #a copy of this software and associated documentation files (the #"Software"), to deal in the Software without restriction, including #without limitation the rights to use, copy, modify, merge, publish, #distribute, sublicense, and/or sell copies of the Software, and to #permit persons to whom the Software is furnished to do so, subject to #the following conditions: # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.