Sha256: 56fe42036125407f8bf155c47fa109d6daf45a5f20c167e9d0685eab39e4166b

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

# encoding: UTF-8
require File.join(File.dirname(__FILE__),'test_helper')

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.8.1 test/cookbook.rb
free-image-0.8.0 test/cookbook.rb