2009-01-01から1ヶ月間の記事一覧

.aco から色のデータを HTML カラーコードにして抽出する

extract_colorcodes_from_aco.rb binary_file = 'test.aco' color_num = 0 colorcodes = [] open(binary_file, 'rb') {|f| f.getc; f.getc # 0001 を読み飛ばす color_num = 256 * f.getc + f.getc # 色数 p color_num until f.eof? colorcode = "" f.getc; …

バイナリファイルの内容表示する

display_binary_file.rb binary_file = 'test.aco' decimal_mode = false #decimal_mode = true item_num = 0 open(binary_file, 'rb') {|f| until f.eof? if decimal_mode print "%5d" % (f.getc * 256 + f.getc) else print "%02x%02x" % [f.getc, f.getc]…