EasyManua.ls Logo

Arduino Pro Mini

Arduino Pro Mini
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Figure 25You can find good online editors for pixel graphics.
When ImageMagick is available on your system, you can install the rmagick
library using the following command:
maik> gem install rmagick
Now you can use rmagick in your Ruby programs. Well use it to convert a
graphics file into a C++ file:
Video/img2cpp.rb
require 'RMagick'
Line 1
include Magick
-
-
image = Image::read(ARGV[0]).first
-
5
puts '#include "thermometer.h"'
-
puts 'PROGMEM const unsigned char thermometer[] = {'
-
puts " #{image.columns}, #{image.rows},"
-
-
(0..image.rows).each do |y|
10
print ' B'
-
(0..image.columns).each do |x|
-
pixel = image.pixel_color(x, y)
-
print pixel.red == 0 ? '0' : '1'
-
print ', B' if (x + 1) % 8 == 0
15
Chapter 8. Generating Video Signals with an Arduino 142
report erratum discuss
www.it-ebooks.info

Table of Contents

Related product manuals