LoginSignup
1
0

wslでelixir その92

Last updated at Posted at 2023-11-05

概要

wsl(wsl2じゃない)で、elixirやってみた。
練習問題、やってみた。

練習問題

bmpファイルをパースせよ。

写真

image.png

サンプルコード

defmodule Bmp do
  def parse(filename) do
    {:ok, bindata} = File.read(filename)
    <<"BM", _:: size(64), 
      offset:: size(32) - little, _:: size(32), 
      width:: size(32) - little, 
      height:: size(32) - little, _:: size(16), 24:: size(16) - little, _rest:: binary>> = bindata
    IO.puts("Offset: #{offset} Width: #{width} Height: #{height}")
  end  
end

Bmp.parse("color.bmp")

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0