Created
September 22, 2011 23:18
-
-
Save erubboli/1236314 to your computer and use it in GitHub Desktop.
convert an image to c array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Convert the 128x128 image with: | |
// convert image.jpg image.rgb | |
res=128 | |
img_file = File.open(ARGV[0],'r') | |
puts "static char image[#{res*res}] = { " | |
img_file.bytes.each_slice(res) do |l| | |
puts " #{l.join(',')}" | |
end | |
puts "}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment