Packages

Adam7 interlacing library for Elixir. Primarily used for interlacing and de-interlacing image data for PNGs.

Current section

Files

Jump to
adam7 lib adam7.ex
Raw

lib/adam7.ex

defmodule Adam7 do
@doc """
Merge the extracted seven passes into a corresponding image.
"""
def merge(passes, {width, height}) do
Enum.reduce(1..7, empty_image_rows(width, height), fn (pass, image_rows) ->
Adam7.Pass.merge(pass, {width, height}, Enum.at(passes, pass-1), image_rows)
end)
|> :array.to_list
|> Enum.map(&:array.to_list/1)
end
defp empty_image_rows(width, height) do
:array.new([
{:size, height},
{:fixed, true},
{:default, :array.new([
{:size, width},
{:fixed, true}
])
}
])
end
end