-
-
Save achedeuzot/d2d7ae40de8cf462df7965ce4b74bddb to your computer and use it in GitHub Desktop.
Revisions
-
bryanhunter created this gist
Jan 20, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ defmodule Bumper do @doc ~S""" Reads a Bitmap (24-bit) and displays width, height, and the RGB of each pixel """ def show(filename) do {:ok, bindata} = File.read(filename) << "BM", _::size(64), offset_to_pixels::size(32)-little, _::size(32), width::size(32)-little, height::size(32)-little, _::size(16), 24::size(16)-little, _rest::binary>> = bindata <<_::size(offset_to_pixels)-bytes, pixels::binary>> = bindata IO.puts "Offset:#{offset_to_pixels} Width:#{width} Height:#{height}" for <<b::size(8), g::size(8), r::size(8) <- pixels >>, do: {r,g,b} end end Bumper.show("krgbw.bmp") |> IO.inspect