###【プログラム概要】
画像のピクセルごとの色を取り出してExcelのセルに塗りつぶします。
こちらのサイトのRuby版を作っています
Excelで佐々木希を描く with python
###【プログラム】
rb:ruby.rb
1require 'writeexcel' 2require 'chunky_png' 3 4image = ChunkyPNG::Image.from_file('sample.png') 5 6width = image.width 7height = image.height 8 9# エクセル作成 10wb = WriteExcel.new("colors.xls") 11ws = wb.add_worksheet('sample sheet') 12 13pul_wh = 0 14row = 0 15col = 0 16 17for w in 1..width do 18 for h in 1..height do 19 # 16進数の色を取り出す 20 hex_color = ChunkyPNG::Color.to_hex(image.pixels[pul_wh])[0,7] 21 # カラーセット 22 color = wb.set_custom_color(40, hex_color) 23 format = wb.add_format( 24 :bg_color => color, 25 :pattern => 1, 26 :border => 0 27 ) 28 29 # セルの塗りつぶし 30 ws.write(row, col, " ", format) 31 pul_wh += 1 32 row += 1 33 end 34 row = 0 35 col += 1 36end 37 38wb.close 39
###【問題点】
プログラムを実行しても43個のセルしか塗りつぶすことができません・・・
全てのセルを塗りつぶしたいのですが、どうすればいいでしょうか?
他のライブラリを使用してもかまいません(>_<)

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/06/14 10:22