defmodule Imagineer.Image.PNG.PngSuite.Basic.PaletteTest do
  use ExUnit.Case, async: true

  @test_path "test/support/images/pngsuite/basic/"
  @tmp_path "./tmp/"

  @actual_pixels [
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ],
    [
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {34, 102, 255},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34},
      {238, 255, 34}
    ]
  ]
  test "1 bit palatte" do
    {:ok, image} = Imagineer.load(@test_path <> "basn3p01.png")

    assert image.height == 32
    assert image.width == 32

    assert image.color_format == :palette
    assert image.compression == :zlib
    assert image.color_type == 3
    assert image.interlace_method == 0
    assert image.gamma == 1.0
    assert image.bit_depth == 1
    assert image.mask == nil
    assert image.format == :png
    assert image.mime_type == "image/png"
    assert :array.to_list(image.palette) == [{238, 255, 34}, {34, 102, 255}]

    assert_pixels_match(image.pixels, @actual_pixels)

    :ok = Imagineer.write(image, @tmp_path <> "basn3p01_test.png")
    {:ok, image} = Imagineer.load(@tmp_path <> "basn3p01_test.png")

    assert image.height == 32
    assert image.width == 32

    assert image.color_format == :palette
    assert image.compression == :zlib
    assert image.color_type == 3
    assert image.interlace_method == 0
    assert image.gamma == 1.0
    assert image.bit_depth == 1
    assert image.mask == nil
    assert image.format == :png
    assert image.mime_type == "image/png"
    assert :array.to_list(image.palette) == [{238, 255, 34}, {34, 102, 255}]

    assert_pixels_match(image.pixels, @actual_pixels)
  end

  @actual_pixels [
    [
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0}
    ],
    [
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0}
    ],
    [
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0}
    ],
    [
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0}
    ],
    [
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0}
    ],
    [
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0}
    ],
    [
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0}
    ],
    [
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0}
    ],
    [
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0}
    ],
    [
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0}
    ],
    [
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0}
    ],
    [
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255}
    ],
    [
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0}
    ],
    [
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0}
    ],
    [
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0}
    ],
    [
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0}
    ],
    [
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0}
    ],
    [
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0}
    ],
    [
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0}
    ],
    [
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0}
    ],
    [
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0}
    ],
    [
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0}
    ],
    [
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0}
    ],
    [
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {255, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 255, 0},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255},
      {0, 0, 255}
    ]
  ]
  test "2 bit palatte" do
    {:ok, image} = Imagineer.load(@test_path <> "basn3p02.png")

    assert image.height == 32
    assert image.width == 32

    assert image.color_format == :palette
    assert image.compression == :zlib
    assert image.color_type == 3
    assert image.interlace_method == 0
    assert image.gamma == 1.0
    assert image.bit_depth == 2
    assert image.mask == nil
    assert image.format == :png
    assert image.mime_type == "image/png"
    assert :array.to_list(image.palette) == [{0, 255, 0}, {255, 0, 0}, {255, 255, 0}, {0, 0, 255}]

    assert_pixels_match(image.pixels, @actual_pixels)

    :ok = Imagineer.write(image, @tmp_path <> "basn3p02_test.png")
    {:ok, image} = Imagineer.load(@tmp_path <> "basn3p02_test.png")

    assert image.height == 32
    assert image.width == 32

    assert image.color_format == :palette
    assert image.compression == :zlib
    assert image.color_type == 3
    assert image.interlace_method == 0
    assert image.gamma == 1.0
    assert image.bit_depth == 2
    assert image.mask == nil
    assert image.format == :png
    assert image.mime_type == "image/png"

    assert Enum.sort(:array.to_list(image.palette)) ==
             Enum.sort([{0, 255, 0}, {255, 0, 0}, {255, 255, 0}, {0, 0, 255}])

    assert_pixels_match(image.pixels, @actual_pixels)
  end

  @actual_pixels [
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153}
    ],
    [
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 0, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153}
    ],
    [
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255}
    ],
    [
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255}
    ],
    [
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255}
    ],
    [
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 102, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255}
    ],
    [
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255}
    ],
    [
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255}
    ],
    [
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255}
    ],
    [
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {255, 187, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255}
    ],
    [
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255}
    ],
    [
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255}
    ],
    [
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255}
    ],
    [
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {221, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255}
    ],
    [
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255}
    ],
    [
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255}
    ],
    [
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255}
    ],
    [
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {119, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255}
    ],
    [
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255}
    ],
    [
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255}
    ],
    [
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255}
    ],
    [
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {34, 255, 0},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255}
    ],
    [
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255}
    ],
    [
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255}
    ],
    [
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255}
    ],
    [
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 68},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255}
    ],
    [
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {255, 0, 187},
      {255, 0, 187},
      {255, 0, 187},
      {255, 0, 187}
    ],
    [
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {255, 0, 187},
      {255, 0, 187},
      {255, 0, 187},
      {255, 0, 187}
    ],
    [
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {255, 0, 187},
      {255, 0, 187},
      {255, 0, 187},
      {255, 0, 187}
    ],
    [
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 153},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 255, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 153, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {0, 68, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {34, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {136, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {221, 0, 255},
      {255, 0, 187},
      {255, 0, 187},
      {255, 0, 187},
      {255, 0, 187}
    ]
  ]
  test "4 bit palatte" do
    {:ok, image} = Imagineer.load(@test_path <> "basn3p04.png")

    assert image.height == 32
    assert image.width == 32

    assert image.color_format == :palette
    assert image.compression == :zlib
    assert image.color_type == 3
    assert image.interlace_method == 0
    assert image.gamma == 1.0
    assert image.bit_depth == 4
    assert image.mask == nil
    assert image.format == :png
    assert image.mime_type == "image/png"

    assert :array.to_list(image.palette) == [
             {34, 0, 255},
             {0, 255, 255},
             {136, 0, 255},
             {34, 255, 0},
             {0, 153, 255},
             {255, 102, 0},
             {221, 0, 255},
             {119, 255, 0},
             {255, 0, 0},
             {0, 255, 153},
             {221, 255, 0},
             {255, 0, 187},
             {255, 187, 0},
             {0, 68, 255},
             {0, 255, 68}
           ]

    assert_pixels_match(image.pixels, @actual_pixels)

    :ok = Imagineer.write(image, @tmp_path <> "basn3p04_test.png")
    {:ok, image} = Imagineer.load(@tmp_path <> "basn3p04_test.png")

    assert image.height == 32
    assert image.width == 32

    assert image.color_format == :palette
    assert image.compression == :zlib
    assert image.color_type == 3
    assert image.interlace_method == 0
    assert image.gamma == 1.0
    assert image.bit_depth == 4
    assert image.mask == nil
    assert image.format == :png
    assert image.mime_type == "image/png"

    assert Enum.sort(:array.to_list(image.palette)) ==
             Enum.sort([
               {34, 0, 255},
               {0, 255, 255},
               {136, 0, 255},
               {34, 255, 0},
               {0, 153, 255},
               {255, 102, 0},
               {221, 0, 255},
               {119, 255, 0},
               {255, 0, 0},
               {0, 255, 153},
               {221, 255, 0},
               {255, 0, 187},
               {255, 187, 0},
               {0, 68, 255},
               {0, 255, 68}
             ])

    assert_pixels_match(image.pixels, @actual_pixels)
  end

  @actual_pixels [
    [
      {1, 0, 0},
      {1, 0, 0},
      {1, 0, 0},
      {1, 0, 0},
      {1, 2, 0},
      {1, 2, 0},
      {1, 2, 0},
      {1, 2, 0},
      {1, 1, 0},
      {1, 1, 0},
      {1, 1, 0},
      {1, 1, 0},
      {2, 1, 0},
      {2, 1, 0},
      {2, 1, 0},
      {2, 1, 0},
      {0, 1, 0},
      {0, 1, 0},
      {0, 1, 0},
      {0, 1, 0},
      {0, 1, 1},
      {0, 1, 1},
      {0, 1, 1},
      {0, 1, 1},
      {0, 0, 1},
      {0, 0, 1},
      {0, 0, 1},
      {0, 0, 1},
      {1, 0, 1},
      {1, 0, 1},
      {1, 0, 1},
      {1, 0, 1}
    ],
    [
      {17, 0, 0},
      {17, 0, 0},
      {17, 0, 0},
      {17, 0, 0},
      {17, 10, 0},
      {17, 10, 0},
      {17, 10, 0},
      {17, 10, 0},
      {17, 17, 0},
      {17, 17, 0},
      {17, 17, 0},
      {17, 17, 0},
      {10, 17, 0},
      {10, 17, 0},
      {10, 17, 0},
      {10, 17, 0},
      {0, 17, 0},
      {0, 17, 0},
      {0, 17, 0},
      {0, 17, 0},
      {0, 17, 17},
      {0, 17, 17},
      {0, 17, 17},
      {0, 17, 17},
      {0, 0, 17},
      {0, 0, 17},
      {0, 0, 17},
      {0, 0, 17},
      {17, 0, 17},
      {17, 0, 17},
      {17, 0, 17},
      {17, 0, 17}
    ],
    [
      {34, 0, 0},
      {34, 0, 0},
      {34, 0, 0},
      {34, 0, 0},
      {34, 18, 0},
      {34, 18, 0},
      {34, 18, 0},
      {34, 18, 0},
      {34, 34, 0},
      {34, 34, 0},
      {34, 34, 0},
      {34, 34, 0},
      {18, 34, 0},
      {18, 34, 0},
      {18, 34, 0},
      {18, 34, 0},
      {0, 34, 0},
      {0, 34, 0},
      {0, 34, 0},
      {0, 34, 0},
      {0, 34, 34},
      {0, 34, 34},
      {0, 34, 34},
      {0, 34, 34},
      {0, 0, 34},
      {0, 0, 34},
      {0, 0, 34},
      {0, 0, 34},
      {34, 0, 34},
      {34, 0, 34},
      {34, 0, 34},
      {34, 0, 34}
    ],
    [
      {51, 0, 0},
      {51, 0, 0},
      {51, 0, 0},
      {51, 0, 0},
      {51, 26, 0},
      {51, 26, 0},
      {51, 26, 0},
      {51, 26, 0},
      {51, 51, 0},
      {51, 51, 0},
      {51, 51, 0},
      {51, 51, 0},
      {26, 51, 0},
      {26, 51, 0},
      {26, 51, 0},
      {26, 51, 0},
      {0, 51, 0},
      {0, 51, 0},
      {0, 51, 0},
      {0, 51, 0},
      {0, 51, 51},
      {0, 51, 51},
      {0, 51, 51},
      {0, 51, 51},
      {0, 0, 51},
      {0, 0, 51},
      {0, 0, 51},
      {0, 0, 51},
      {51, 0, 51},
      {51, 0, 51},
      {51, 0, 51},
      {51, 0, 51}
    ],
    [
      {68, 0, 0},
      {68, 0, 0},
      {68, 0, 0},
      {68, 0, 0},
      {68, 34, 0},
      {68, 34, 0},
      {68, 34, 0},
      {68, 34, 0},
      {68, 68, 0},
      {68, 68, 0},
      {68, 68, 0},
      {68, 68, 0},
      {34, 68, 0},
      {34, 68, 0},
      {34, 68, 0},
      {34, 68, 0},
      {0, 68, 0},
      {0, 68, 0},
      {0, 68, 0},
      {0, 68, 0},
      {0, 68, 68},
      {0, 68, 68},
      {0, 68, 68},
      {0, 68, 68},
      {0, 0, 68},
      {0, 0, 68},
      {0, 0, 68},
      {0, 0, 68},
      {68, 0, 68},
      {68, 0, 68},
      {68, 0, 68},
      {68, 0, 68}
    ],
    [
      {85, 0, 0},
      {85, 0, 0},
      {85, 0, 0},
      {85, 0, 0},
      {85, 42, 0},
      {85, 42, 0},
      {85, 42, 0},
      {85, 42, 0},
      {85, 85, 0},
      {85, 85, 0},
      {85, 85, 0},
      {85, 85, 0},
      {42, 85, 0},
      {42, 85, 0},
      {42, 85, 0},
      {42, 85, 0},
      {0, 85, 0},
      {0, 85, 0},
      {0, 85, 0},
      {0, 85, 0},
      {0, 85, 85},
      {0, 85, 85},
      {0, 85, 85},
      {0, 85, 85},
      {0, 0, 85},
      {0, 0, 85},
      {0, 0, 85},
      {0, 0, 85},
      {85, 0, 85},
      {85, 0, 85},
      {85, 0, 85},
      {85, 0, 85}
    ],
    [
      {102, 0, 0},
      {102, 0, 0},
      {102, 0, 0},
      {102, 0, 0},
      {102, 50, 0},
      {102, 50, 0},
      {102, 50, 0},
      {102, 50, 0},
      {102, 102, 0},
      {102, 102, 0},
      {102, 102, 0},
      {102, 102, 0},
      {50, 102, 0},
      {50, 102, 0},
      {50, 102, 0},
      {50, 102, 0},
      {0, 102, 0},
      {0, 102, 0},
      {0, 102, 0},
      {0, 102, 0},
      {0, 102, 102},
      {0, 102, 102},
      {0, 102, 102},
      {0, 102, 102},
      {0, 0, 102},
      {0, 0, 102},
      {0, 0, 102},
      {0, 0, 102},
      {102, 0, 102},
      {102, 0, 102},
      {102, 0, 102},
      {102, 0, 102}
    ],
    [
      {119, 0, 0},
      {119, 0, 0},
      {119, 0, 0},
      {119, 0, 0},
      {119, 58, 0},
      {119, 58, 0},
      {119, 58, 0},
      {119, 58, 0},
      {119, 119, 0},
      {119, 119, 0},
      {119, 119, 0},
      {119, 119, 0},
      {58, 119, 0},
      {58, 119, 0},
      {58, 119, 0},
      {58, 119, 0},
      {0, 119, 0},
      {0, 119, 0},
      {0, 119, 0},
      {0, 119, 0},
      {0, 119, 119},
      {0, 119, 119},
      {0, 119, 119},
      {0, 119, 119},
      {0, 0, 119},
      {0, 0, 119},
      {0, 0, 119},
      {0, 0, 119},
      {119, 0, 119},
      {119, 0, 119},
      {119, 0, 119},
      {119, 0, 119}
    ],
    [
      {136, 0, 0},
      {136, 0, 0},
      {136, 0, 0},
      {136, 0, 0},
      {136, 66, 0},
      {136, 66, 0},
      {136, 66, 0},
      {136, 66, 0},
      {136, 136, 0},
      {136, 136, 0},
      {136, 136, 0},
      {136, 136, 0},
      {66, 136, 0},
      {66, 136, 0},
      {66, 136, 0},
      {66, 136, 0},
      {0, 136, 0},
      {0, 136, 0},
      {0, 136, 0},
      {0, 136, 0},
      {0, 136, 136},
      {0, 136, 136},
      {0, 136, 136},
      {0, 136, 136},
      {0, 0, 136},
      {0, 0, 136},
      {0, 0, 136},
      {0, 0, 136},
      {136, 0, 136},
      {136, 0, 136},
      {136, 0, 136},
      {136, 0, 136}
    ],
    [
      {153, 0, 0},
      {153, 0, 0},
      {153, 0, 0},
      {153, 0, 0},
      {153, 74, 0},
      {153, 74, 0},
      {153, 74, 0},
      {153, 74, 0},
      {153, 153, 0},
      {153, 153, 0},
      {153, 153, 0},
      {153, 153, 0},
      {74, 153, 0},
      {74, 153, 0},
      {74, 153, 0},
      {74, 153, 0},
      {0, 153, 0},
      {0, 153, 0},
      {0, 153, 0},
      {0, 153, 0},
      {0, 153, 153},
      {0, 153, 153},
      {0, 153, 153},
      {0, 153, 153},
      {0, 0, 153},
      {0, 0, 153},
      {0, 0, 153},
      {0, 0, 153},
      {153, 0, 153},
      {153, 0, 153},
      {153, 0, 153},
      {153, 0, 153}
    ],
    [
      {170, 0, 0},
      {170, 0, 0},
      {170, 0, 0},
      {170, 0, 0},
      {170, 83, 0},
      {170, 83, 0},
      {170, 83, 0},
      {170, 83, 0},
      {170, 170, 0},
      {170, 170, 0},
      {170, 170, 0},
      {170, 170, 0},
      {83, 170, 0},
      {83, 170, 0},
      {83, 170, 0},
      {83, 170, 0},
      {0, 170, 0},
      {0, 170, 0},
      {0, 170, 0},
      {0, 170, 0},
      {0, 170, 170},
      {0, 170, 170},
      {0, 170, 170},
      {0, 170, 170},
      {0, 0, 170},
      {0, 0, 170},
      {0, 0, 170},
      {0, 0, 170},
      {170, 0, 170},
      {170, 0, 170},
      {170, 0, 170},
      {170, 0, 170}
    ],
    [
      {186, 0, 0},
      {186, 0, 0},
      {186, 0, 0},
      {186, 0, 0},
      {186, 91, 0},
      {186, 91, 0},
      {186, 91, 0},
      {186, 91, 0},
      {186, 186, 0},
      {186, 186, 0},
      {186, 186, 0},
      {186, 186, 0},
      {91, 186, 0},
      {91, 186, 0},
      {91, 186, 0},
      {91, 186, 0},
      {0, 186, 0},
      {0, 186, 0},
      {0, 186, 0},
      {0, 186, 0},
      {0, 186, 186},
      {0, 186, 186},
      {0, 186, 186},
      {0, 186, 186},
      {0, 0, 186},
      {0, 0, 186},
      {0, 0, 186},
      {0, 0, 186},
      {186, 0, 186},
      {186, 0, 186},
      {186, 0, 186},
      {186, 0, 186}
    ],
    [
      {203, 0, 0},
      {203, 0, 0},
      {203, 0, 0},
      {203, 0, 0},
      {203, 99, 0},
      {203, 99, 0},
      {203, 99, 0},
      {203, 99, 0},
      {203, 203, 0},
      {203, 203, 0},
      {203, 203, 0},
      {203, 203, 0},
      {99, 203, 0},
      {99, 203, 0},
      {99, 203, 0},
      {99, 203, 0},
      {0, 203, 0},
      {0, 203, 0},
      {0, 203, 0},
      {0, 203, 0},
      {0, 203, 203},
      {0, 203, 203},
      {0, 203, 203},
      {0, 203, 203},
      {0, 0, 203},
      {0, 0, 203},
      {0, 0, 203},
      {0, 0, 203},
      {203, 0, 203},
      {203, 0, 203},
      {203, 0, 203},
      {203, 0, 203}
    ],
    [
      {220, 0, 0},
      {220, 0, 0},
      {220, 0, 0},
      {220, 0, 0},
      {220, 107, 0},
      {220, 107, 0},
      {220, 107, 0},
      {220, 107, 0},
      {220, 220, 0},
      {220, 220, 0},
      {220, 220, 0},
      {220, 220, 0},
      {107, 220, 0},
      {107, 220, 0},
      {107, 220, 0},
      {107, 220, 0},
      {0, 220, 0},
      {0, 220, 0},
      {0, 220, 0},
      {0, 220, 0},
      {0, 220, 220},
      {0, 220, 220},
      {0, 220, 220},
      {0, 220, 220},
      {0, 0, 220},
      {0, 0, 220},
      {0, 0, 220},
      {0, 0, 220},
      {220, 0, 220},
      {220, 0, 220},
      {220, 0, 220},
      {220, 0, 220}
    ],
    [
      {237, 0, 0},
      {237, 0, 0},
      {237, 0, 0},
      {237, 0, 0},
      {237, 115, 0},
      {237, 115, 0},
      {237, 115, 0},
      {237, 115, 0},
      {237, 237, 0},
      {237, 237, 0},
      {237, 237, 0},
      {237, 237, 0},
      {115, 237, 0},
      {115, 237, 0},
      {115, 237, 0},
      {115, 237, 0},
      {0, 237, 0},
      {0, 237, 0},
      {0, 237, 0},
      {0, 237, 0},
      {0, 237, 237},
      {0, 237, 237},
      {0, 237, 237},
      {0, 237, 237},
      {0, 0, 237},
      {0, 0, 237},
      {0, 0, 237},
      {0, 0, 237},
      {237, 0, 237},
      {237, 0, 237},
      {237, 0, 237},
      {237, 0, 237}
    ],
    [
      {254, 0, 0},
      {254, 0, 0},
      {254, 0, 0},
      {254, 0, 0},
      {254, 123, 0},
      {254, 123, 0},
      {254, 123, 0},
      {254, 123, 0},
      {254, 254, 0},
      {254, 254, 0},
      {254, 254, 0},
      {254, 254, 0},
      {123, 254, 0},
      {123, 254, 0},
      {123, 254, 0},
      {123, 254, 0},
      {0, 254, 0},
      {0, 254, 0},
      {0, 254, 0},
      {0, 254, 0},
      {0, 254, 254},
      {0, 254, 254},
      {0, 254, 254},
      {0, 254, 254},
      {0, 0, 254},
      {0, 0, 254},
      {0, 0, 254},
      {0, 0, 254},
      {254, 0, 254},
      {254, 0, 254},
      {254, 0, 254},
      {254, 0, 254}
    ],
    [
      {255, 1, 1},
      {255, 1, 1},
      {255, 1, 1},
      {255, 1, 1},
      {255, 131, 1},
      {255, 131, 1},
      {255, 131, 1},
      {255, 131, 1},
      {255, 255, 1},
      {255, 255, 1},
      {255, 255, 1},
      {255, 255, 1},
      {131, 255, 1},
      {131, 255, 1},
      {131, 255, 1},
      {131, 255, 1},
      {1, 255, 1},
      {1, 255, 1},
      {1, 255, 1},
      {1, 255, 1},
      {1, 255, 255},
      {1, 255, 255},
      {1, 255, 255},
      {1, 255, 255},
      {1, 1, 255},
      {1, 1, 255},
      {1, 1, 255},
      {1, 1, 255},
      {255, 1, 255},
      {255, 1, 255},
      {255, 1, 255},
      {255, 1, 255}
    ],
    [
      {255, 17, 17},
      {255, 17, 17},
      {255, 17, 17},
      {255, 17, 17},
      {255, 139, 17},
      {255, 139, 17},
      {255, 139, 17},
      {255, 139, 17},
      {255, 255, 17},
      {255, 255, 17},
      {255, 255, 17},
      {255, 255, 17},
      {139, 255, 17},
      {139, 255, 17},
      {139, 255, 17},
      {139, 255, 17},
      {17, 255, 17},
      {17, 255, 17},
      {17, 255, 17},
      {17, 255, 17},
      {17, 255, 255},
      {17, 255, 255},
      {17, 255, 255},
      {17, 255, 255},
      {17, 17, 255},
      {17, 17, 255},
      {17, 17, 255},
      {17, 17, 255},
      {255, 17, 255},
      {255, 17, 255},
      {255, 17, 255},
      {255, 17, 255}
    ],
    [
      {255, 34, 34},
      {255, 34, 34},
      {255, 34, 34},
      {255, 34, 34},
      {255, 147, 34},
      {255, 147, 34},
      {255, 147, 34},
      {255, 147, 34},
      {255, 255, 34},
      {255, 255, 34},
      {255, 255, 34},
      {255, 255, 34},
      {147, 255, 34},
      {147, 255, 34},
      {147, 255, 34},
      {147, 255, 34},
      {34, 255, 34},
      {34, 255, 34},
      {34, 255, 34},
      {34, 255, 34},
      {34, 255, 255},
      {34, 255, 255},
      {34, 255, 255},
      {34, 255, 255},
      {34, 34, 255},
      {34, 34, 255},
      {34, 34, 255},
      {34, 34, 255},
      {255, 34, 255},
      {255, 34, 255},
      {255, 34, 255},
      {255, 34, 255}
    ],
    [
      {255, 51, 51},
      {255, 51, 51},
      {255, 51, 51},
      {255, 51, 51},
      {255, 155, 51},
      {255, 155, 51},
      {255, 155, 51},
      {255, 155, 51},
      {255, 255, 51},
      {255, 255, 51},
      {255, 255, 51},
      {255, 255, 51},
      {155, 255, 51},
      {155, 255, 51},
      {155, 255, 51},
      {155, 255, 51},
      {51, 255, 51},
      {51, 255, 51},
      {51, 255, 51},
      {51, 255, 51},
      {51, 255, 255},
      {51, 255, 255},
      {51, 255, 255},
      {51, 255, 255},
      {51, 51, 255},
      {51, 51, 255},
      {51, 51, 255},
      {51, 51, 255},
      {255, 51, 255},
      {255, 51, 255},
      {255, 51, 255},
      {255, 51, 255}
    ],
    [
      {255, 68, 68},
      {255, 68, 68},
      {255, 68, 68},
      {255, 68, 68},
      {255, 164, 68},
      {255, 164, 68},
      {255, 164, 68},
      {255, 164, 68},
      {255, 255, 68},
      {255, 255, 68},
      {255, 255, 68},
      {255, 255, 68},
      {164, 255, 68},
      {164, 255, 68},
      {164, 255, 68},
      {164, 255, 68},
      {68, 255, 68},
      {68, 255, 68},
      {68, 255, 68},
      {68, 255, 68},
      {68, 255, 255},
      {68, 255, 255},
      {68, 255, 255},
      {68, 255, 255},
      {68, 68, 255},
      {68, 68, 255},
      {68, 68, 255},
      {68, 68, 255},
      {255, 68, 255},
      {255, 68, 255},
      {255, 68, 255},
      {255, 68, 255}
    ],
    [
      {255, 85, 85},
      {255, 85, 85},
      {255, 85, 85},
      {255, 85, 85},
      {255, 172, 85},
      {255, 172, 85},
      {255, 172, 85},
      {255, 172, 85},
      {255, 255, 85},
      {255, 255, 85},
      {255, 255, 85},
      {255, 255, 85},
      {172, 255, 85},
      {172, 255, 85},
      {172, 255, 85},
      {172, 255, 85},
      {85, 255, 85},
      {85, 255, 85},
      {85, 255, 85},
      {85, 255, 85},
      {85, 255, 255},
      {85, 255, 255},
      {85, 255, 255},
      {85, 255, 255},
      {85, 85, 255},
      {85, 85, 255},
      {85, 85, 255},
      {85, 85, 255},
      {255, 85, 255},
      {255, 85, 255},
      {255, 85, 255},
      {255, 85, 255}
    ],
    [
      {255, 102, 102},
      {255, 102, 102},
      {255, 102, 102},
      {255, 102, 102},
      {255, 180, 102},
      {255, 180, 102},
      {255, 180, 102},
      {255, 180, 102},
      {255, 255, 102},
      {255, 255, 102},
      {255, 255, 102},
      {255, 255, 102},
      {180, 255, 102},
      {180, 255, 102},
      {180, 255, 102},
      {180, 255, 102},
      {102, 255, 102},
      {102, 255, 102},
      {102, 255, 102},
      {102, 255, 102},
      {102, 255, 255},
      {102, 255, 255},
      {102, 255, 255},
      {102, 255, 255},
      {102, 102, 255},
      {102, 102, 255},
      {102, 102, 255},
      {102, 102, 255},
      {255, 102, 255},
      {255, 102, 255},
      {255, 102, 255},
      {255, 102, 255}
    ],
    [
      {255, 119, 119},
      {255, 119, 119},
      {255, 119, 119},
      {255, 119, 119},
      {255, 188, 119},
      {255, 188, 119},
      {255, 188, 119},
      {255, 188, 119},
      {255, 255, 119},
      {255, 255, 119},
      {255, 255, 119},
      {255, 255, 119},
      {188, 255, 119},
      {188, 255, 119},
      {188, 255, 119},
      {188, 255, 119},
      {119, 255, 119},
      {119, 255, 119},
      {119, 255, 119},
      {119, 255, 119},
      {119, 255, 255},
      {119, 255, 255},
      {119, 255, 255},
      {119, 255, 255},
      {119, 119, 255},
      {119, 119, 255},
      {119, 119, 255},
      {119, 119, 255},
      {255, 119, 255},
      {255, 119, 255},
      {255, 119, 255},
      {255, 119, 255}
    ],
    [
      {255, 136, 136},
      {255, 136, 136},
      {255, 136, 136},
      {255, 136, 136},
      {255, 196, 136},
      {255, 196, 136},
      {255, 196, 136},
      {255, 196, 136},
      {255, 255, 136},
      {255, 255, 136},
      {255, 255, 136},
      {255, 255, 136},
      {196, 255, 136},
      {196, 255, 136},
      {196, 255, 136},
      {196, 255, 136},
      {136, 255, 136},
      {136, 255, 136},
      {136, 255, 136},
      {136, 255, 136},
      {136, 255, 255},
      {136, 255, 255},
      {136, 255, 255},
      {136, 255, 255},
      {136, 136, 255},
      {136, 136, 255},
      {136, 136, 255},
      {136, 136, 255},
      {255, 136, 255},
      {255, 136, 255},
      {255, 136, 255},
      {255, 136, 255}
    ],
    [
      {255, 153, 153},
      {255, 153, 153},
      {255, 153, 153},
      {255, 153, 153},
      {255, 204, 153},
      {255, 204, 153},
      {255, 204, 153},
      {255, 204, 153},
      {255, 255, 153},
      {255, 255, 153},
      {255, 255, 153},
      {255, 255, 153},
      {204, 255, 153},
      {204, 255, 153},
      {204, 255, 153},
      {204, 255, 153},
      {153, 255, 153},
      {153, 255, 153},
      {153, 255, 153},
      {153, 255, 153},
      {153, 255, 255},
      {153, 255, 255},
      {153, 255, 255},
      {153, 255, 255},
      {153, 153, 255},
      {153, 153, 255},
      {153, 153, 255},
      {153, 153, 255},
      {255, 153, 255},
      {255, 153, 255},
      {255, 153, 255},
      {255, 153, 255}
    ],
    [
      {255, 170, 170},
      {255, 170, 170},
      {255, 170, 170},
      {255, 170, 170},
      {255, 212, 170},
      {255, 212, 170},
      {255, 212, 170},
      {255, 212, 170},
      {255, 255, 170},
      {255, 255, 170},
      {255, 255, 170},
      {255, 255, 170},
      {212, 255, 170},
      {212, 255, 170},
      {212, 255, 170},
      {212, 255, 170},
      {170, 255, 170},
      {170, 255, 170},
      {170, 255, 170},
      {170, 255, 170},
      {170, 255, 255},
      {170, 255, 255},
      {170, 255, 255},
      {170, 255, 255},
      {170, 170, 255},
      {170, 170, 255},
      {170, 170, 255},
      {170, 170, 255},
      {255, 170, 255},
      {255, 170, 255},
      {255, 170, 255},
      {255, 170, 255}
    ],
    [
      {255, 186, 186},
      {255, 186, 186},
      {255, 186, 186},
      {255, 186, 186},
      {255, 220, 186},
      {255, 220, 186},
      {255, 220, 186},
      {255, 220, 186},
      {255, 255, 186},
      {255, 255, 186},
      {255, 255, 186},
      {255, 255, 186},
      {220, 255, 186},
      {220, 255, 186},
      {220, 255, 186},
      {220, 255, 186},
      {186, 255, 186},
      {186, 255, 186},
      {186, 255, 186},
      {186, 255, 186},
      {186, 255, 255},
      {186, 255, 255},
      {186, 255, 255},
      {186, 255, 255},
      {186, 186, 255},
      {186, 186, 255},
      {186, 186, 255},
      {186, 186, 255},
      {255, 186, 255},
      {255, 186, 255},
      {255, 186, 255},
      {255, 186, 255}
    ],
    [
      {255, 203, 203},
      {255, 203, 203},
      {255, 203, 203},
      {255, 203, 203},
      {255, 228, 203},
      {255, 228, 203},
      {255, 228, 203},
      {255, 228, 203},
      {255, 255, 203},
      {255, 255, 203},
      {255, 255, 203},
      {255, 255, 203},
      {228, 255, 203},
      {228, 255, 203},
      {228, 255, 203},
      {228, 255, 203},
      {203, 255, 203},
      {203, 255, 203},
      {203, 255, 203},
      {203, 255, 203},
      {203, 255, 255},
      {203, 255, 255},
      {203, 255, 255},
      {203, 255, 255},
      {203, 203, 255},
      {203, 203, 255},
      {203, 203, 255},
      {203, 203, 255},
      {255, 203, 255},
      {255, 203, 255},
      {255, 203, 255},
      {255, 203, 255}
    ],
    [
      {255, 220, 220},
      {255, 220, 220},
      {255, 220, 220},
      {255, 220, 220},
      {255, 236, 220},
      {255, 236, 220},
      {255, 236, 220},
      {255, 236, 220},
      {255, 255, 220},
      {255, 255, 220},
      {255, 255, 220},
      {255, 255, 220},
      {236, 255, 220},
      {236, 255, 220},
      {236, 255, 220},
      {236, 255, 220},
      {220, 255, 220},
      {220, 255, 220},
      {220, 255, 220},
      {220, 255, 220},
      {220, 255, 255},
      {220, 255, 255},
      {220, 255, 255},
      {220, 255, 255},
      {220, 220, 255},
      {220, 220, 255},
      {220, 220, 255},
      {220, 220, 255},
      {255, 220, 255},
      {255, 220, 255},
      {255, 220, 255},
      {255, 220, 255}
    ],
    [
      {255, 237, 237},
      {255, 237, 237},
      {255, 237, 237},
      {255, 237, 237},
      {255, 245, 237},
      {255, 245, 237},
      {255, 245, 237},
      {255, 245, 237},
      {255, 255, 237},
      {255, 255, 237},
      {255, 255, 237},
      {255, 255, 237},
      {245, 255, 237},
      {245, 255, 237},
      {245, 255, 237},
      {245, 255, 237},
      {237, 255, 237},
      {237, 255, 237},
      {237, 255, 237},
      {237, 255, 237},
      {237, 255, 255},
      {237, 255, 255},
      {237, 255, 255},
      {237, 255, 255},
      {237, 237, 255},
      {237, 237, 255},
      {237, 237, 255},
      {237, 237, 255},
      {255, 237, 255},
      {255, 237, 255},
      {255, 237, 255},
      {255, 237, 255}
    ],
    [
      {255, 254, 254},
      {255, 254, 254},
      {255, 254, 254},
      {255, 254, 254},
      {255, 253, 254},
      {255, 253, 254},
      {255, 253, 254},
      {255, 253, 254},
      {255, 255, 254},
      {255, 255, 254},
      {255, 255, 254},
      {255, 255, 254},
      {253, 255, 254},
      {253, 255, 254},
      {253, 255, 254},
      {253, 255, 254},
      {254, 255, 254},
      {254, 255, 254},
      {254, 255, 254},
      {254, 255, 254},
      {254, 255, 255},
      {254, 255, 255},
      {254, 255, 255},
      {254, 255, 255},
      {254, 254, 255},
      {254, 254, 255},
      {254, 254, 255},
      {254, 254, 255},
      {255, 254, 255},
      {255, 254, 255},
      {255, 254, 255},
      {255, 254, 255}
    ]
  ]
  test "8 bit palatte" do
    {:ok, image} = Imagineer.load(@test_path <> "basn3p08.png")

    assert image.height == 32
    assert image.width == 32

    assert image.color_format == :palette
    assert image.compression == :zlib
    assert image.color_type == 3
    assert image.interlace_method == 0
    assert image.gamma == 1.0
    assert image.bit_depth == 8
    assert image.mask == nil
    assert image.format == :png
    assert image.mime_type == "image/png"

    assert Enum.sort(:array.to_list(image.palette)) ==
             Enum.sort(Enum.uniq(List.flatten(@actual_pixels)))

    assert_pixels_match(image.pixels, @actual_pixels)

    :ok = Imagineer.write(image, @tmp_path <> "basn3p08_test.png")
    {:ok, image} = Imagineer.load(@tmp_path <> "basn3p08_test.png")

    assert image.height == 32
    assert image.width == 32

    assert image.color_format == :palette
    assert image.compression == :zlib
    assert image.color_type == 3
    assert image.interlace_method == 0
    assert image.gamma == 1.0
    assert image.bit_depth == 8
    assert image.mask == nil
    assert image.format == :png
    assert image.mime_type == "image/png"

    assert Enum.sort(:array.to_list(image.palette)) ==
             Enum.sort(Enum.uniq(List.flatten(@actual_pixels)))

    assert_pixels_match(image.pixels, @actual_pixels)
  end

  defp assert_pixels_match(parsed_pixels, actual_pixels) do
    Enum.zip(parsed_pixels, actual_pixels)
    |> Enum.with_index()
    |> Enum.each(fn
      {{parsed, actual}, index} ->
        assert(actual == parsed, """
          row #{index + 1} is fucked
          \texpected: #{inspect(actual)}
          \tgot: #{inspect(parsed)}
        """)
    end)
  end
end
