Sha256: 76a0aefe9dbe5cc4f76bc78af247642a2bd77ab82ec53a4b11187ab36fd60bb2
Contents?: true
Size: 975 Bytes
Versions: 4
Compression:
Stored size: 975 Bytes
Contents
# encoding: UTF-8 require './test_helper' require 'test/unit' def set_to_red(color) color[:red] = 255 color[:green] = 0 color[:blue] = 0 end image = FreeImage::Bitmap.open('images/lena.png') thumbnail = image.make_thumbnail(100) # Make the bottom row red scanline = thumbnail.scanline(0) # Draw bottom border (0..3).each do |index| scanline = thumbnail.scanline(index) scanline.each do |color| set_to_red(color) end end # Draw top border ((thumbnail.height - 5)..(thumbnail.height - 1)).each do |index| scanline = thumbnail.scanline(index) scanline.each do |color| set_to_red(color) end end # Draw left and right borders (1..(thumbnail.height - 2)).each do |index| scanline = thumbnail.scanline(index) (0..4).each do |index| set_to_red(scanline[index]) end ((thumbnail.width - 5)..(thumbnail.width - 1)).each do |index| set_to_red(scanline[index]) end end thumbnail.save("images/lena_thumbnail_border_scanline.png", :png)
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
free-image-0.6.2 | test/cookbook.rb |
free-image-0.6.1 | test/cookbook.rb |
free-image-0.6.0 | test/cookbook.rb |
free-image-0.5.0 | test/cookbook.rb |