# File lib/pixels.rb, line 87
 87:   def self.open_tga(file_or_path)
 88:     if file_or_path.respond_to?(:read)
 89:       file = file_or_path
 90:     else
 91:       file = File.open(file_or_path, "rb:binary")
 92:     end
 93: 
 94:     raw_header = file.read(18)
 95:     h, r = decode_tga_header(raw_header)
 96:     case [h[:bits_per_pixel], r[:alpha_depth]]
 97:     when [16, 0]
 98:       return Targa15.new(file, h, r, 2)
 99:     when [16, 1]
100:       return Targa16.new(file, h, r, 2)
101:     when [24, 0]
102:       return Targa24.new(file, h, r, 3)
103:     when [32, 0]
104:       return Targa24.new(file, h, r, 4)
105:     when [32, 8]
106:       return Targa32.new(file, h, r, 4)
107:     else
108:       raise DataFormatError.new(
109:         "#{h[:bits_per_pixel]} bpp with #{h[:alpha_depth]}-bit alpha channel not supported")
110:     end
111:   end