Tools for working with Cidco Mailstations
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xpm_to_icon: better XPM parsing

+22 -10
+22 -10
util/xpm_to_icon.rb
··· 59 59 raise "image should be 34x34, not #{width}x#{height}" 60 60 end 61 61 62 - line = xpm.gets 63 - if line.match(/^\" \tc None/) 64 - # skip 62 + blank = nil 63 + black = nil 64 + 2.times do 65 65 line = xpm.gets 66 - end 66 + if line.match(/^\" \tc None/) 67 + # skip 68 + line = xpm.gets 69 + end 67 70 68 - if !(m = line.match(/^\"(.)\tc #FFFFFF/)) 69 - raise "unexpected line: #{line.inspect}" 71 + if !(m = line.match(/^\"(.)\tc #(FFFFFF|000000)/)) 72 + raise "unexpected line: #{line.inspect}" 73 + end 74 + if m[2][0] == "F" 75 + blank = m[1] 76 + elsif m[2][0] == "0" 77 + black = m[1] 78 + else 79 + raise "unexpected color: #{line.inspect}" 80 + end 70 81 end 71 - blank = m[1] 72 82 73 - if !(m = (line = xpm.gets).match(/^\"(.)\tc #000000/)) 74 - raise "unexpected line: #{line.inspect}" 83 + if !blank 84 + raise "no blank color found" 75 85 end 76 - black = m[1] 86 + if !black 87 + raise "no black color found" 88 + end 77 89 78 90 puts "icon0:" 79 91 puts "\t.dw\t##{sprintf("0x%02x", width)}\t\t\t; icon width (#{width})"