2014-06-28 :-)
_ [ガールズ&パンツァー][ガルパン][サンスポ]サンスポ特別版「ガールズ&パンツァー新聞」
サンスポ特別版「ガールズ&パンツァー新聞」明日発売!ねんどろ沙織予約受付開始! ガールズ&パンツァー公式ブログ/ウェブリブログ
コンビニで買えるらしいので手当たり次第に寄ったところサークルKサンクスにあったので買った。
_ [PGM]PGM を読む
ファイルの中身はこんな。世界一有名な女性なのではないかと レナ (画像データ) - Wikipedia
とりあえず読むだけ
ruby
# conding: utf-8
class PGM
:ST_MAGICK
:ST_SIZE
:ST_GRAY
:ST_DATA
def initialize()
@stat = :ST_MAGICK
end
def read( filepath )
magick = ""
width = 0
length = 0
gray = 0
data = nil
filesize = File::stat( filepath ).size
pgm = File.open( filepath ).read( filesize )
pgm.each_line {|line|
case @stat
when :ST_MAGICK
next if line =~ /^#/
magick = line
@stat = :ST_SIZE
when :ST_SIZE
next if line =~ /^#/
sp = line.split()
width = sp[ 0 ].to_i
length = sp[ 1 ].to_i
@stat = :ST_GRAY
when :ST_GRAY
next if line =~ /^#/
gray = line.to_i
@stat = :ST_DATA
when :ST_DATA
data = line.unpack("C*")
end
}
puts "magick: #{magick}"
puts "width: #{width}"
puts "length: #{length}"
puts "gray: #{gray}"
# puts "data: #{data}"
end
end
def main(argv)
pgm = PGM.new()
pgm.read(argv[0])
end
main(ARGV)
参考: PGM ‐ 通信用語の基礎知識
[ツッコミを入れる]









