Skip to content

Instantly share code, notes, and snippets.

@erubboli
Created September 22, 2011 23:18
Show Gist options
  • Save erubboli/1236314 to your computer and use it in GitHub Desktop.
Save erubboli/1236314 to your computer and use it in GitHub Desktop.
convert an image to c array
//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