Sha256: 41eb1ce0fd469419f8f9ec530262cd3040bfd36a81b4e2a03c824af018942d97
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
# encoding: UTF-8 require File.join(File.dirname(__FILE__),'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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
free-image-0.7.1 | test/cookbook.rb |
free-image-0.7.0 | test/cookbook.rb |