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

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

  @actual_pixels [
    [
      {255, 255, 255},
      {255, 255, 254},
      {255, 255, 253},
      {255, 255, 252},
      {255, 255, 251},
      {255, 255, 250},
      {255, 255, 249},
      {255, 255, 248},
      {255, 255, 247},
      {255, 255, 246},
      {255, 255, 245},
      {255, 255, 244},
      {255, 255, 243},
      {255, 255, 242},
      {255, 255, 241},
      {255, 255, 240},
      {255, 255, 239},
      {255, 255, 238},
      {255, 255, 237},
      {255, 255, 236},
      {255, 255, 235},
      {255, 255, 234},
      {255, 255, 233},
      {255, 255, 232},
      {255, 255, 231},
      {255, 255, 230},
      {255, 255, 229},
      {255, 255, 228},
      {255, 255, 227},
      {255, 255, 226},
      {255, 255, 225},
      {255, 255, 224}
    ],
    [
      {255, 255, 223},
      {255, 255, 222},
      {255, 255, 221},
      {255, 255, 220},
      {255, 255, 219},
      {255, 255, 218},
      {255, 255, 217},
      {255, 255, 216},
      {255, 255, 215},
      {255, 255, 214},
      {255, 255, 213},
      {255, 255, 212},
      {255, 255, 211},
      {255, 255, 210},
      {255, 255, 209},
      {255, 255, 208},
      {255, 255, 207},
      {255, 255, 206},
      {255, 255, 205},
      {255, 255, 204},
      {255, 255, 203},
      {255, 255, 202},
      {255, 255, 201},
      {255, 255, 200},
      {255, 255, 199},
      {255, 255, 198},
      {255, 255, 197},
      {255, 255, 196},
      {255, 255, 195},
      {255, 255, 194},
      {255, 255, 193},
      {255, 255, 192}
    ],
    [
      {255, 255, 191},
      {255, 255, 190},
      {255, 255, 189},
      {255, 255, 188},
      {255, 255, 187},
      {255, 255, 186},
      {255, 255, 185},
      {255, 255, 184},
      {255, 255, 183},
      {255, 255, 182},
      {255, 255, 181},
      {255, 255, 180},
      {255, 255, 179},
      {255, 255, 178},
      {255, 255, 177},
      {255, 255, 176},
      {255, 255, 175},
      {255, 255, 174},
      {255, 255, 173},
      {255, 255, 172},
      {255, 255, 171},
      {255, 255, 170},
      {255, 255, 169},
      {255, 255, 168},
      {255, 255, 167},
      {255, 255, 166},
      {255, 255, 165},
      {255, 255, 164},
      {255, 255, 163},
      {255, 255, 162},
      {255, 255, 161},
      {255, 255, 160}
    ],
    [
      {255, 255, 159},
      {255, 255, 158},
      {255, 255, 157},
      {255, 255, 156},
      {255, 255, 155},
      {255, 255, 154},
      {255, 255, 153},
      {255, 255, 152},
      {255, 255, 151},
      {255, 255, 150},
      {255, 255, 149},
      {255, 255, 148},
      {255, 255, 147},
      {255, 255, 146},
      {255, 255, 145},
      {255, 255, 144},
      {255, 255, 143},
      {255, 255, 142},
      {255, 255, 141},
      {255, 255, 140},
      {255, 255, 139},
      {255, 255, 138},
      {255, 255, 137},
      {255, 255, 136},
      {255, 255, 135},
      {255, 255, 134},
      {255, 255, 133},
      {255, 255, 132},
      {255, 255, 131},
      {255, 255, 130},
      {255, 255, 129},
      {255, 255, 128}
    ],
    [
      {255, 255, 127},
      {255, 255, 126},
      {255, 255, 125},
      {255, 255, 124},
      {255, 255, 123},
      {255, 255, 122},
      {255, 255, 121},
      {255, 255, 120},
      {255, 255, 119},
      {255, 255, 118},
      {255, 255, 117},
      {255, 255, 116},
      {255, 255, 115},
      {255, 255, 114},
      {255, 255, 113},
      {255, 255, 112},
      {255, 255, 111},
      {255, 255, 110},
      {255, 255, 109},
      {255, 255, 108},
      {255, 255, 107},
      {255, 255, 106},
      {255, 255, 105},
      {255, 255, 104},
      {255, 255, 103},
      {255, 255, 102},
      {255, 255, 101},
      {255, 255, 100},
      {255, 255, 99},
      {255, 255, 98},
      {255, 255, 97},
      {255, 255, 96}
    ],
    [
      {255, 255, 95},
      {255, 255, 94},
      {255, 255, 93},
      {255, 255, 92},
      {255, 255, 91},
      {255, 255, 90},
      {255, 255, 89},
      {255, 255, 88},
      {255, 255, 87},
      {255, 255, 86},
      {255, 255, 85},
      {255, 255, 84},
      {255, 255, 83},
      {255, 255, 82},
      {255, 255, 81},
      {255, 255, 80},
      {255, 255, 79},
      {255, 255, 78},
      {255, 255, 77},
      {255, 255, 76},
      {255, 255, 75},
      {255, 255, 74},
      {255, 255, 73},
      {255, 255, 72},
      {255, 255, 71},
      {255, 255, 70},
      {255, 255, 69},
      {255, 255, 68},
      {255, 255, 67},
      {255, 255, 66},
      {255, 255, 65},
      {255, 255, 64}
    ],
    [
      {255, 255, 63},
      {255, 255, 62},
      {255, 255, 61},
      {255, 255, 60},
      {255, 255, 59},
      {255, 255, 58},
      {255, 255, 57},
      {255, 255, 56},
      {255, 255, 55},
      {255, 255, 54},
      {255, 255, 53},
      {255, 255, 52},
      {255, 255, 51},
      {255, 255, 50},
      {255, 255, 49},
      {255, 255, 48},
      {255, 255, 47},
      {255, 255, 46},
      {255, 255, 45},
      {255, 255, 44},
      {255, 255, 43},
      {255, 255, 42},
      {255, 255, 41},
      {255, 255, 40},
      {255, 255, 39},
      {255, 255, 38},
      {255, 255, 37},
      {255, 255, 36},
      {255, 255, 35},
      {255, 255, 34},
      {255, 255, 33},
      {255, 255, 32}
    ],
    [
      {255, 255, 31},
      {255, 255, 30},
      {255, 255, 29},
      {255, 255, 28},
      {255, 255, 27},
      {255, 255, 26},
      {255, 255, 25},
      {255, 255, 24},
      {255, 255, 23},
      {255, 255, 22},
      {255, 255, 21},
      {255, 255, 20},
      {255, 255, 19},
      {255, 255, 18},
      {255, 255, 17},
      {255, 255, 16},
      {255, 255, 15},
      {255, 255, 14},
      {255, 255, 13},
      {255, 255, 12},
      {255, 255, 11},
      {255, 255, 10},
      {255, 255, 9},
      {255, 255, 8},
      {255, 255, 7},
      {255, 255, 6},
      {255, 255, 5},
      {255, 255, 4},
      {255, 255, 3},
      {255, 255, 2},
      {255, 255, 1},
      {255, 255, 0}
    ],
    [
      {255, 255, 255},
      {255, 254, 255},
      {255, 253, 255},
      {255, 252, 255},
      {255, 251, 255},
      {255, 250, 255},
      {255, 249, 255},
      {255, 248, 255},
      {255, 247, 255},
      {255, 246, 255},
      {255, 245, 255},
      {255, 244, 255},
      {255, 243, 255},
      {255, 242, 255},
      {255, 241, 255},
      {255, 240, 255},
      {255, 239, 255},
      {255, 238, 255},
      {255, 237, 255},
      {255, 236, 255},
      {255, 235, 255},
      {255, 234, 255},
      {255, 233, 255},
      {255, 232, 255},
      {255, 231, 255},
      {255, 230, 255},
      {255, 229, 255},
      {255, 228, 255},
      {255, 227, 255},
      {255, 226, 255},
      {255, 225, 255},
      {255, 224, 255}
    ],
    [
      {255, 223, 255},
      {255, 222, 255},
      {255, 221, 255},
      {255, 220, 255},
      {255, 219, 255},
      {255, 218, 255},
      {255, 217, 255},
      {255, 216, 255},
      {255, 215, 255},
      {255, 214, 255},
      {255, 213, 255},
      {255, 212, 255},
      {255, 211, 255},
      {255, 210, 255},
      {255, 209, 255},
      {255, 208, 255},
      {255, 207, 255},
      {255, 206, 255},
      {255, 205, 255},
      {255, 204, 255},
      {255, 203, 255},
      {255, 202, 255},
      {255, 201, 255},
      {255, 200, 255},
      {255, 199, 255},
      {255, 198, 255},
      {255, 197, 255},
      {255, 196, 255},
      {255, 195, 255},
      {255, 194, 255},
      {255, 193, 255},
      {255, 192, 255}
    ],
    [
      {255, 191, 255},
      {255, 190, 255},
      {255, 189, 255},
      {255, 188, 255},
      {255, 187, 255},
      {255, 186, 255},
      {255, 185, 255},
      {255, 184, 255},
      {255, 183, 255},
      {255, 182, 255},
      {255, 181, 255},
      {255, 180, 255},
      {255, 179, 255},
      {255, 178, 255},
      {255, 177, 255},
      {255, 176, 255},
      {255, 175, 255},
      {255, 174, 255},
      {255, 173, 255},
      {255, 172, 255},
      {255, 171, 255},
      {255, 170, 255},
      {255, 169, 255},
      {255, 168, 255},
      {255, 167, 255},
      {255, 166, 255},
      {255, 165, 255},
      {255, 164, 255},
      {255, 163, 255},
      {255, 162, 255},
      {255, 161, 255},
      {255, 160, 255}
    ],
    [
      {255, 159, 255},
      {255, 158, 255},
      {255, 157, 255},
      {255, 156, 255},
      {255, 155, 255},
      {255, 154, 255},
      {255, 153, 255},
      {255, 152, 255},
      {255, 151, 255},
      {255, 150, 255},
      {255, 149, 255},
      {255, 148, 255},
      {255, 147, 255},
      {255, 146, 255},
      {255, 145, 255},
      {255, 144, 255},
      {255, 143, 255},
      {255, 142, 255},
      {255, 141, 255},
      {255, 140, 255},
      {255, 139, 255},
      {255, 138, 255},
      {255, 137, 255},
      {255, 136, 255},
      {255, 135, 255},
      {255, 134, 255},
      {255, 133, 255},
      {255, 132, 255},
      {255, 131, 255},
      {255, 130, 255},
      {255, 129, 255},
      {255, 128, 255}
    ],
    [
      {255, 127, 255},
      {255, 126, 255},
      {255, 125, 255},
      {255, 124, 255},
      {255, 123, 255},
      {255, 122, 255},
      {255, 121, 255},
      {255, 120, 255},
      {255, 119, 255},
      {255, 118, 255},
      {255, 117, 255},
      {255, 116, 255},
      {255, 115, 255},
      {255, 114, 255},
      {255, 113, 255},
      {255, 112, 255},
      {255, 111, 255},
      {255, 110, 255},
      {255, 109, 255},
      {255, 108, 255},
      {255, 107, 255},
      {255, 106, 255},
      {255, 105, 255},
      {255, 104, 255},
      {255, 103, 255},
      {255, 102, 255},
      {255, 101, 255},
      {255, 100, 255},
      {255, 99, 255},
      {255, 98, 255},
      {255, 97, 255},
      {255, 96, 255}
    ],
    [
      {255, 95, 255},
      {255, 94, 255},
      {255, 93, 255},
      {255, 92, 255},
      {255, 91, 255},
      {255, 90, 255},
      {255, 89, 255},
      {255, 88, 255},
      {255, 87, 255},
      {255, 86, 255},
      {255, 85, 255},
      {255, 84, 255},
      {255, 83, 255},
      {255, 82, 255},
      {255, 81, 255},
      {255, 80, 255},
      {255, 79, 255},
      {255, 78, 255},
      {255, 77, 255},
      {255, 76, 255},
      {255, 75, 255},
      {255, 74, 255},
      {255, 73, 255},
      {255, 72, 255},
      {255, 71, 255},
      {255, 70, 255},
      {255, 69, 255},
      {255, 68, 255},
      {255, 67, 255},
      {255, 66, 255},
      {255, 65, 255},
      {255, 64, 255}
    ],
    [
      {255, 63, 255},
      {255, 62, 255},
      {255, 61, 255},
      {255, 60, 255},
      {255, 59, 255},
      {255, 58, 255},
      {255, 57, 255},
      {255, 56, 255},
      {255, 55, 255},
      {255, 54, 255},
      {255, 53, 255},
      {255, 52, 255},
      {255, 51, 255},
      {255, 50, 255},
      {255, 49, 255},
      {255, 48, 255},
      {255, 47, 255},
      {255, 46, 255},
      {255, 45, 255},
      {255, 44, 255},
      {255, 43, 255},
      {255, 42, 255},
      {255, 41, 255},
      {255, 40, 255},
      {255, 39, 255},
      {255, 38, 255},
      {255, 37, 255},
      {255, 36, 255},
      {255, 35, 255},
      {255, 34, 255},
      {255, 33, 255},
      {255, 32, 255}
    ],
    [
      {255, 31, 255},
      {255, 30, 255},
      {255, 29, 255},
      {255, 28, 255},
      {255, 27, 255},
      {255, 26, 255},
      {255, 25, 255},
      {255, 24, 255},
      {255, 23, 255},
      {255, 22, 255},
      {255, 21, 255},
      {255, 20, 255},
      {255, 19, 255},
      {255, 18, 255},
      {255, 17, 255},
      {255, 16, 255},
      {255, 15, 255},
      {255, 14, 255},
      {255, 13, 255},
      {255, 12, 255},
      {255, 11, 255},
      {255, 10, 255},
      {255, 9, 255},
      {255, 8, 255},
      {255, 7, 255},
      {255, 6, 255},
      {255, 5, 255},
      {255, 4, 255},
      {255, 3, 255},
      {255, 2, 255},
      {255, 1, 255},
      {255, 0, 255}
    ],
    [
      {255, 255, 255},
      {254, 255, 255},
      {253, 255, 255},
      {252, 255, 255},
      {251, 255, 255},
      {250, 255, 255},
      {249, 255, 255},
      {248, 255, 255},
      {247, 255, 255},
      {246, 255, 255},
      {245, 255, 255},
      {244, 255, 255},
      {243, 255, 255},
      {242, 255, 255},
      {241, 255, 255},
      {240, 255, 255},
      {239, 255, 255},
      {238, 255, 255},
      {237, 255, 255},
      {236, 255, 255},
      {235, 255, 255},
      {234, 255, 255},
      {233, 255, 255},
      {232, 255, 255},
      {231, 255, 255},
      {230, 255, 255},
      {229, 255, 255},
      {228, 255, 255},
      {227, 255, 255},
      {226, 255, 255},
      {225, 255, 255},
      {224, 255, 255}
    ],
    [
      {223, 255, 255},
      {222, 255, 255},
      {221, 255, 255},
      {220, 255, 255},
      {219, 255, 255},
      {218, 255, 255},
      {217, 255, 255},
      {216, 255, 255},
      {215, 255, 255},
      {214, 255, 255},
      {213, 255, 255},
      {212, 255, 255},
      {211, 255, 255},
      {210, 255, 255},
      {209, 255, 255},
      {208, 255, 255},
      {207, 255, 255},
      {206, 255, 255},
      {205, 255, 255},
      {204, 255, 255},
      {203, 255, 255},
      {202, 255, 255},
      {201, 255, 255},
      {200, 255, 255},
      {199, 255, 255},
      {198, 255, 255},
      {197, 255, 255},
      {196, 255, 255},
      {195, 255, 255},
      {194, 255, 255},
      {193, 255, 255},
      {192, 255, 255}
    ],
    [
      {191, 255, 255},
      {190, 255, 255},
      {189, 255, 255},
      {188, 255, 255},
      {187, 255, 255},
      {186, 255, 255},
      {185, 255, 255},
      {184, 255, 255},
      {183, 255, 255},
      {182, 255, 255},
      {181, 255, 255},
      {180, 255, 255},
      {179, 255, 255},
      {178, 255, 255},
      {177, 255, 255},
      {176, 255, 255},
      {175, 255, 255},
      {174, 255, 255},
      {173, 255, 255},
      {172, 255, 255},
      {171, 255, 255},
      {170, 255, 255},
      {169, 255, 255},
      {168, 255, 255},
      {167, 255, 255},
      {166, 255, 255},
      {165, 255, 255},
      {164, 255, 255},
      {163, 255, 255},
      {162, 255, 255},
      {161, 255, 255},
      {160, 255, 255}
    ],
    [
      {159, 255, 255},
      {158, 255, 255},
      {157, 255, 255},
      {156, 255, 255},
      {155, 255, 255},
      {154, 255, 255},
      {153, 255, 255},
      {152, 255, 255},
      {151, 255, 255},
      {150, 255, 255},
      {149, 255, 255},
      {148, 255, 255},
      {147, 255, 255},
      {146, 255, 255},
      {145, 255, 255},
      {144, 255, 255},
      {143, 255, 255},
      {142, 255, 255},
      {141, 255, 255},
      {140, 255, 255},
      {139, 255, 255},
      {138, 255, 255},
      {137, 255, 255},
      {136, 255, 255},
      {135, 255, 255},
      {134, 255, 255},
      {133, 255, 255},
      {132, 255, 255},
      {131, 255, 255},
      {130, 255, 255},
      {129, 255, 255},
      {128, 255, 255}
    ],
    [
      {127, 255, 255},
      {126, 255, 255},
      {125, 255, 255},
      {124, 255, 255},
      {123, 255, 255},
      {122, 255, 255},
      {121, 255, 255},
      {120, 255, 255},
      {119, 255, 255},
      {118, 255, 255},
      {117, 255, 255},
      {116, 255, 255},
      {115, 255, 255},
      {114, 255, 255},
      {113, 255, 255},
      {112, 255, 255},
      {111, 255, 255},
      {110, 255, 255},
      {109, 255, 255},
      {108, 255, 255},
      {107, 255, 255},
      {106, 255, 255},
      {105, 255, 255},
      {104, 255, 255},
      {103, 255, 255},
      {102, 255, 255},
      {101, 255, 255},
      {100, 255, 255},
      {99, 255, 255},
      {98, 255, 255},
      {97, 255, 255},
      {96, 255, 255}
    ],
    [
      {95, 255, 255},
      {94, 255, 255},
      {93, 255, 255},
      {92, 255, 255},
      {91, 255, 255},
      {90, 255, 255},
      {89, 255, 255},
      {88, 255, 255},
      {87, 255, 255},
      {86, 255, 255},
      {85, 255, 255},
      {84, 255, 255},
      {83, 255, 255},
      {82, 255, 255},
      {81, 255, 255},
      {80, 255, 255},
      {79, 255, 255},
      {78, 255, 255},
      {77, 255, 255},
      {76, 255, 255},
      {75, 255, 255},
      {74, 255, 255},
      {73, 255, 255},
      {72, 255, 255},
      {71, 255, 255},
      {70, 255, 255},
      {69, 255, 255},
      {68, 255, 255},
      {67, 255, 255},
      {66, 255, 255},
      {65, 255, 255},
      {64, 255, 255}
    ],
    [
      {63, 255, 255},
      {62, 255, 255},
      {61, 255, 255},
      {60, 255, 255},
      {59, 255, 255},
      {58, 255, 255},
      {57, 255, 255},
      {56, 255, 255},
      {55, 255, 255},
      {54, 255, 255},
      {53, 255, 255},
      {52, 255, 255},
      {51, 255, 255},
      {50, 255, 255},
      {49, 255, 255},
      {48, 255, 255},
      {47, 255, 255},
      {46, 255, 255},
      {45, 255, 255},
      {44, 255, 255},
      {43, 255, 255},
      {42, 255, 255},
      {41, 255, 255},
      {40, 255, 255},
      {39, 255, 255},
      {38, 255, 255},
      {37, 255, 255},
      {36, 255, 255},
      {35, 255, 255},
      {34, 255, 255},
      {33, 255, 255},
      {32, 255, 255}
    ],
    [
      {31, 255, 255},
      {30, 255, 255},
      {29, 255, 255},
      {28, 255, 255},
      {27, 255, 255},
      {26, 255, 255},
      {25, 255, 255},
      {24, 255, 255},
      {23, 255, 255},
      {22, 255, 255},
      {21, 255, 255},
      {20, 255, 255},
      {19, 255, 255},
      {18, 255, 255},
      {17, 255, 255},
      {16, 255, 255},
      {15, 255, 255},
      {14, 255, 255},
      {13, 255, 255},
      {12, 255, 255},
      {11, 255, 255},
      {10, 255, 255},
      {9, 255, 255},
      {8, 255, 255},
      {7, 255, 255},
      {6, 255, 255},
      {5, 255, 255},
      {4, 255, 255},
      {3, 255, 255},
      {2, 255, 255},
      {1, 255, 255},
      {0, 255, 255}
    ],
    [
      {255, 255, 255},
      {254, 254, 254},
      {253, 253, 253},
      {252, 252, 252},
      {251, 251, 251},
      {250, 250, 250},
      {249, 249, 249},
      {248, 248, 248},
      {247, 247, 247},
      {246, 246, 246},
      {245, 245, 245},
      {244, 244, 244},
      {243, 243, 243},
      {242, 242, 242},
      {241, 241, 241},
      {240, 240, 240},
      {239, 239, 239},
      {238, 238, 238},
      {237, 237, 237},
      {236, 236, 236},
      {235, 235, 235},
      {234, 234, 234},
      {233, 233, 233},
      {232, 232, 232},
      {231, 231, 231},
      {230, 230, 230},
      {229, 229, 229},
      {228, 228, 228},
      {227, 227, 227},
      {226, 226, 226},
      {225, 225, 225},
      {224, 224, 224}
    ],
    [
      {223, 223, 223},
      {222, 222, 222},
      {221, 221, 221},
      {220, 220, 220},
      {219, 219, 219},
      {218, 218, 218},
      {217, 217, 217},
      {216, 216, 216},
      {215, 215, 215},
      {214, 214, 214},
      {213, 213, 213},
      {212, 212, 212},
      {211, 211, 211},
      {210, 210, 210},
      {209, 209, 209},
      {208, 208, 208},
      {207, 207, 207},
      {206, 206, 206},
      {205, 205, 205},
      {204, 204, 204},
      {203, 203, 203},
      {202, 202, 202},
      {201, 201, 201},
      {200, 200, 200},
      {199, 199, 199},
      {198, 198, 198},
      {197, 197, 197},
      {196, 196, 196},
      {195, 195, 195},
      {194, 194, 194},
      {193, 193, 193},
      {192, 192, 192}
    ],
    [
      {191, 191, 191},
      {190, 190, 190},
      {189, 189, 189},
      {188, 188, 188},
      {187, 187, 187},
      {186, 186, 186},
      {185, 185, 185},
      {184, 184, 184},
      {183, 183, 183},
      {182, 182, 182},
      {181, 181, 181},
      {180, 180, 180},
      {179, 179, 179},
      {178, 178, 178},
      {177, 177, 177},
      {176, 176, 176},
      {175, 175, 175},
      {174, 174, 174},
      {173, 173, 173},
      {172, 172, 172},
      {171, 171, 171},
      {170, 170, 170},
      {169, 169, 169},
      {168, 168, 168},
      {167, 167, 167},
      {166, 166, 166},
      {165, 165, 165},
      {164, 164, 164},
      {163, 163, 163},
      {162, 162, 162},
      {161, 161, 161},
      {160, 160, 160}
    ],
    [
      {159, 159, 159},
      {158, 158, 158},
      {157, 157, 157},
      {156, 156, 156},
      {155, 155, 155},
      {154, 154, 154},
      {153, 153, 153},
      {152, 152, 152},
      {151, 151, 151},
      {150, 150, 150},
      {149, 149, 149},
      {148, 148, 148},
      {147, 147, 147},
      {146, 146, 146},
      {145, 145, 145},
      {144, 144, 144},
      {143, 143, 143},
      {142, 142, 142},
      {141, 141, 141},
      {140, 140, 140},
      {139, 139, 139},
      {138, 138, 138},
      {137, 137, 137},
      {136, 136, 136},
      {135, 135, 135},
      {134, 134, 134},
      {133, 133, 133},
      {132, 132, 132},
      {131, 131, 131},
      {130, 130, 130},
      {129, 129, 129},
      {128, 128, 128}
    ],
    [
      {127, 127, 127},
      {126, 126, 126},
      {125, 125, 125},
      {124, 124, 124},
      {123, 123, 123},
      {122, 122, 122},
      {121, 121, 121},
      {120, 120, 120},
      {119, 119, 119},
      {118, 118, 118},
      {117, 117, 117},
      {116, 116, 116},
      {115, 115, 115},
      {114, 114, 114},
      {113, 113, 113},
      {112, 112, 112},
      {111, 111, 111},
      {110, 110, 110},
      {109, 109, 109},
      {108, 108, 108},
      {107, 107, 107},
      {106, 106, 106},
      {105, 105, 105},
      {104, 104, 104},
      {103, 103, 103},
      {102, 102, 102},
      {101, 101, 101},
      {100, 100, 100},
      {99, 99, 99},
      {98, 98, 98},
      {97, 97, 97},
      {96, 96, 96}
    ],
    [
      {95, 95, 95},
      {94, 94, 94},
      {93, 93, 93},
      {92, 92, 92},
      {91, 91, 91},
      {90, 90, 90},
      {89, 89, 89},
      {88, 88, 88},
      {87, 87, 87},
      {86, 86, 86},
      {85, 85, 85},
      {84, 84, 84},
      {83, 83, 83},
      {82, 82, 82},
      {81, 81, 81},
      {80, 80, 80},
      {79, 79, 79},
      {78, 78, 78},
      {77, 77, 77},
      {76, 76, 76},
      {75, 75, 75},
      {74, 74, 74},
      {73, 73, 73},
      {72, 72, 72},
      {71, 71, 71},
      {70, 70, 70},
      {69, 69, 69},
      {68, 68, 68},
      {67, 67, 67},
      {66, 66, 66},
      {65, 65, 65},
      {64, 64, 64}
    ],
    [
      {63, 63, 63},
      {62, 62, 62},
      {61, 61, 61},
      {60, 60, 60},
      {59, 59, 59},
      {58, 58, 58},
      {57, 57, 57},
      {56, 56, 56},
      {55, 55, 55},
      {54, 54, 54},
      {53, 53, 53},
      {52, 52, 52},
      {51, 51, 51},
      {50, 50, 50},
      {49, 49, 49},
      {48, 48, 48},
      {47, 47, 47},
      {46, 46, 46},
      {45, 45, 45},
      {44, 44, 44},
      {43, 43, 43},
      {42, 42, 42},
      {41, 41, 41},
      {40, 40, 40},
      {39, 39, 39},
      {38, 38, 38},
      {37, 37, 37},
      {36, 36, 36},
      {35, 35, 35},
      {34, 34, 34},
      {33, 33, 33},
      {32, 32, 32}
    ],
    [
      {31, 31, 31},
      {30, 30, 30},
      {29, 29, 29},
      {28, 28, 28},
      {27, 27, 27},
      {26, 26, 26},
      {25, 25, 25},
      {24, 24, 24},
      {23, 23, 23},
      {22, 22, 22},
      {21, 21, 21},
      {20, 20, 20},
      {19, 19, 19},
      {18, 18, 18},
      {17, 17, 17},
      {16, 16, 16},
      {15, 15, 15},
      {14, 14, 14},
      {13, 13, 13},
      {12, 12, 12},
      {11, 11, 11},
      {10, 10, 10},
      {9, 9, 9},
      {8, 8, 8},
      {7, 7, 7},
      {6, 6, 6},
      {5, 5, 5},
      {4, 4, 4},
      {3, 3, 3},
      {2, 2, 2},
      {1, 1, 1},
      {0, 0, 0}
    ]
  ]
  test "8 bit rgb" do
    {:ok, image} = Imagineer.load(@test_path <> "basn2c08.png")

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

    assert image.color_format == :rgb
    assert image.compression == :zlib
    assert image.color_type == 2
    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 image.palette == []

    assert_pixels_match(image.pixels, @actual_pixels)

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

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

    assert image.color_format == :rgb
    assert image.compression == :zlib
    assert image.color_type == 2
    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 image.palette == []

    assert_pixels_match(image.pixels, @actual_pixels)
  end

  @actual_pixels [
    [
      {65535, 65535, 0},
      {63421, 65535, 0},
      {61307, 65535, 0},
      {59193, 65535, 0},
      {57079, 65535, 0},
      {54965, 65535, 0},
      {52851, 65535, 0},
      {50737, 65535, 0},
      {48623, 65535, 0},
      {46509, 65535, 0},
      {44395, 65535, 0},
      {42281, 65535, 0},
      {40167, 65535, 0},
      {38053, 65535, 0},
      {35939, 65535, 0},
      {33825, 65535, 0},
      {31710, 65535, 0},
      {29596, 65535, 0},
      {27482, 65535, 0},
      {25368, 65535, 0},
      {23254, 65535, 0},
      {21140, 65535, 0},
      {19026, 65535, 0},
      {16912, 65535, 0},
      {14798, 65535, 0},
      {12684, 65535, 0},
      {10570, 65535, 0},
      {8456, 65535, 0},
      {6342, 65535, 0},
      {4228, 65535, 0},
      {2114, 65535, 0},
      {0, 65535, 0}
    ],
    [
      {65535, 63421, 0},
      {63421, 63421, 0},
      {61307, 63421, 0},
      {59193, 63421, 0},
      {57079, 63421, 0},
      {54965, 63421, 0},
      {52851, 63421, 0},
      {50737, 63421, 0},
      {48623, 63421, 0},
      {46509, 63421, 0},
      {44395, 63421, 0},
      {42281, 63421, 0},
      {40167, 63421, 0},
      {38053, 63421, 0},
      {35939, 63421, 0},
      {33825, 63421, 0},
      {31710, 63421, 0},
      {29596, 63421, 0},
      {27482, 63421, 0},
      {25368, 63421, 0},
      {23254, 63421, 0},
      {21140, 63421, 0},
      {19026, 63421, 0},
      {16912, 63421, 0},
      {14798, 63421, 0},
      {12684, 63421, 0},
      {10570, 63421, 0},
      {8456, 63421, 0},
      {6342, 63421, 0},
      {4228, 63421, 0},
      {2114, 63421, 0},
      {0, 63421, 2114}
    ],
    [
      {65535, 61307, 0},
      {63421, 61307, 0},
      {61307, 61307, 0},
      {59193, 61307, 0},
      {57079, 61307, 0},
      {54965, 61307, 0},
      {52851, 61307, 0},
      {50737, 61307, 0},
      {48623, 61307, 0},
      {46509, 61307, 0},
      {44395, 61307, 0},
      {42281, 61307, 0},
      {40167, 61307, 0},
      {38053, 61307, 0},
      {35939, 61307, 0},
      {33825, 61307, 0},
      {31710, 61307, 0},
      {29596, 61307, 0},
      {27482, 61307, 0},
      {25368, 61307, 0},
      {23254, 61307, 0},
      {21140, 61307, 0},
      {19026, 61307, 0},
      {16912, 61307, 0},
      {14798, 61307, 0},
      {12684, 61307, 0},
      {10570, 61307, 0},
      {8456, 61307, 0},
      {6342, 61307, 0},
      {4228, 61307, 0},
      {2114, 61307, 2114},
      {0, 61307, 4228}
    ],
    [
      {65535, 59193, 0},
      {63421, 59193, 0},
      {61307, 59193, 0},
      {59193, 59193, 0},
      {57079, 59193, 0},
      {54965, 59193, 0},
      {52851, 59193, 0},
      {50737, 59193, 0},
      {48623, 59193, 0},
      {46509, 59193, 0},
      {44395, 59193, 0},
      {42281, 59193, 0},
      {40167, 59193, 0},
      {38053, 59193, 0},
      {35939, 59193, 0},
      {33825, 59193, 0},
      {31710, 59193, 0},
      {29596, 59193, 0},
      {27482, 59193, 0},
      {25368, 59193, 0},
      {23254, 59193, 0},
      {21140, 59193, 0},
      {19026, 59193, 0},
      {16912, 59193, 0},
      {14798, 59193, 0},
      {12684, 59193, 0},
      {10570, 59193, 0},
      {8456, 59193, 0},
      {6342, 59193, 0},
      {4228, 59193, 2114},
      {2114, 59193, 4228},
      {0, 59193, 6342}
    ],
    [
      {65535, 57079, 0},
      {63421, 57079, 0},
      {61307, 57079, 0},
      {59193, 57079, 0},
      {57079, 57079, 0},
      {54965, 57079, 0},
      {52851, 57079, 0},
      {50737, 57079, 0},
      {48623, 57079, 0},
      {46509, 57079, 0},
      {44395, 57079, 0},
      {42281, 57079, 0},
      {40167, 57079, 0},
      {38053, 57079, 0},
      {35939, 57079, 0},
      {33825, 57079, 0},
      {31710, 57079, 0},
      {29596, 57079, 0},
      {27482, 57079, 0},
      {25368, 57079, 0},
      {23254, 57079, 0},
      {21140, 57079, 0},
      {19026, 57079, 0},
      {16912, 57079, 0},
      {14798, 57079, 0},
      {12684, 57079, 0},
      {10570, 57079, 0},
      {8456, 57079, 0},
      {6342, 57079, 2114},
      {4228, 57079, 4228},
      {2114, 57079, 6342},
      {0, 57079, 8456}
    ],
    [
      {65535, 54965, 0},
      {63421, 54965, 0},
      {61307, 54965, 0},
      {59193, 54965, 0},
      {57079, 54965, 0},
      {54965, 54965, 0},
      {52851, 54965, 0},
      {50737, 54965, 0},
      {48623, 54965, 0},
      {46509, 54965, 0},
      {44395, 54965, 0},
      {42281, 54965, 0},
      {40167, 54965, 0},
      {38053, 54965, 0},
      {35939, 54965, 0},
      {33825, 54965, 0},
      {31710, 54965, 0},
      {29596, 54965, 0},
      {27482, 54965, 0},
      {25368, 54965, 0},
      {23254, 54965, 0},
      {21140, 54965, 0},
      {19026, 54965, 0},
      {16912, 54965, 0},
      {14798, 54965, 0},
      {12684, 54965, 0},
      {10570, 54965, 0},
      {8456, 54965, 2114},
      {6342, 54965, 4228},
      {4228, 54965, 6342},
      {2114, 54965, 8456},
      {0, 54965, 10570}
    ],
    [
      {65535, 52851, 0},
      {63421, 52851, 0},
      {61307, 52851, 0},
      {59193, 52851, 0},
      {57079, 52851, 0},
      {54965, 52851, 0},
      {52851, 52851, 0},
      {50737, 52851, 0},
      {48623, 52851, 0},
      {46509, 52851, 0},
      {44395, 52851, 0},
      {42281, 52851, 0},
      {40167, 52851, 0},
      {38053, 52851, 0},
      {35939, 52851, 0},
      {33825, 52851, 0},
      {31710, 52851, 0},
      {29596, 52851, 0},
      {27482, 52851, 0},
      {25368, 52851, 0},
      {23254, 52851, 0},
      {21140, 52851, 0},
      {19026, 52851, 0},
      {16912, 52851, 0},
      {14798, 52851, 0},
      {12684, 52851, 0},
      {10570, 52851, 2114},
      {8456, 52851, 4228},
      {6342, 52851, 6342},
      {4228, 52851, 8456},
      {2114, 52851, 10570},
      {0, 52851, 12684}
    ],
    [
      {65535, 50737, 0},
      {63421, 50737, 0},
      {61307, 50737, 0},
      {59193, 50737, 0},
      {57079, 50737, 0},
      {54965, 50737, 0},
      {52851, 50737, 0},
      {50737, 50737, 0},
      {48623, 50737, 0},
      {46509, 50737, 0},
      {44395, 50737, 0},
      {42281, 50737, 0},
      {40167, 50737, 0},
      {38053, 50737, 0},
      {35939, 50737, 0},
      {33825, 50737, 0},
      {31710, 50737, 0},
      {29596, 50737, 0},
      {27482, 50737, 0},
      {25368, 50737, 0},
      {23254, 50737, 0},
      {21140, 50737, 0},
      {19026, 50737, 0},
      {16912, 50737, 0},
      {14798, 50737, 0},
      {12684, 50737, 2114},
      {10570, 50737, 4228},
      {8456, 50737, 6342},
      {6342, 50737, 8456},
      {4228, 50737, 10570},
      {2114, 50737, 12684},
      {0, 50737, 14798}
    ],
    [
      {65535, 48623, 0},
      {63421, 48623, 0},
      {61307, 48623, 0},
      {59193, 48623, 0},
      {57079, 48623, 0},
      {54965, 48623, 0},
      {52851, 48623, 0},
      {50737, 48623, 0},
      {48623, 48623, 0},
      {46509, 48623, 0},
      {44395, 48623, 0},
      {42281, 48623, 0},
      {40167, 48623, 0},
      {38053, 48623, 0},
      {35939, 48623, 0},
      {33825, 48623, 0},
      {31710, 48623, 0},
      {29596, 48623, 0},
      {27482, 48623, 0},
      {25368, 48623, 0},
      {23254, 48623, 0},
      {21140, 48623, 0},
      {19026, 48623, 0},
      {16912, 48623, 0},
      {14798, 48623, 2114},
      {12684, 48623, 4228},
      {10570, 48623, 6342},
      {8456, 48623, 8456},
      {6342, 48623, 10570},
      {4228, 48623, 12684},
      {2114, 48623, 14798},
      {0, 48623, 16912}
    ],
    [
      {65535, 46509, 0},
      {63421, 46509, 0},
      {61307, 46509, 0},
      {59193, 46509, 0},
      {57079, 46509, 0},
      {54965, 46509, 0},
      {52851, 46509, 0},
      {50737, 46509, 0},
      {48623, 46509, 0},
      {46509, 46509, 0},
      {44395, 46509, 0},
      {42281, 46509, 0},
      {40167, 46509, 0},
      {38053, 46509, 0},
      {35939, 46509, 0},
      {33825, 46509, 0},
      {31710, 46509, 0},
      {29596, 46509, 0},
      {27482, 46509, 0},
      {25368, 46509, 0},
      {23254, 46509, 0},
      {21140, 46509, 0},
      {19026, 46509, 0},
      {16912, 46509, 2114},
      {14798, 46509, 4228},
      {12684, 46509, 6342},
      {10570, 46509, 8456},
      {8456, 46509, 10570},
      {6342, 46509, 12684},
      {4228, 46509, 14798},
      {2114, 46509, 16912},
      {0, 46509, 19026}
    ],
    [
      {65535, 44395, 0},
      {63421, 44395, 0},
      {61307, 44395, 0},
      {59193, 44395, 0},
      {57079, 44395, 0},
      {54965, 44395, 0},
      {52851, 44395, 0},
      {50737, 44395, 0},
      {48623, 44395, 0},
      {46509, 44395, 0},
      {44395, 44395, 0},
      {42281, 44395, 0},
      {40167, 44395, 0},
      {38053, 44395, 0},
      {35939, 44395, 0},
      {33825, 44395, 0},
      {31710, 44395, 0},
      {29596, 44395, 0},
      {27482, 44395, 0},
      {25368, 44395, 0},
      {23254, 44395, 0},
      {21140, 44395, 0},
      {19026, 44395, 2114},
      {16912, 44395, 4228},
      {14798, 44395, 6342},
      {12684, 44395, 8456},
      {10570, 44395, 10570},
      {8456, 44395, 12684},
      {6342, 44395, 14798},
      {4228, 44395, 16912},
      {2114, 44395, 19026},
      {0, 44395, 21140}
    ],
    [
      {65535, 42281, 0},
      {63421, 42281, 0},
      {61307, 42281, 0},
      {59193, 42281, 0},
      {57079, 42281, 0},
      {54965, 42281, 0},
      {52851, 42281, 0},
      {50737, 42281, 0},
      {48623, 42281, 0},
      {46509, 42281, 0},
      {44395, 42281, 0},
      {42281, 42281, 0},
      {40167, 42281, 0},
      {38053, 42281, 0},
      {35939, 42281, 0},
      {33825, 42281, 0},
      {31710, 42281, 0},
      {29596, 42281, 0},
      {27482, 42281, 0},
      {25368, 42281, 0},
      {23254, 42281, 0},
      {21140, 42281, 2114},
      {19026, 42281, 4228},
      {16912, 42281, 6342},
      {14798, 42281, 8456},
      {12684, 42281, 10570},
      {10570, 42281, 12684},
      {8456, 42281, 14798},
      {6342, 42281, 16912},
      {4228, 42281, 19026},
      {2114, 42281, 21140},
      {0, 42281, 23254}
    ],
    [
      {65535, 40167, 0},
      {63421, 40167, 0},
      {61307, 40167, 0},
      {59193, 40167, 0},
      {57079, 40167, 0},
      {54965, 40167, 0},
      {52851, 40167, 0},
      {50737, 40167, 0},
      {48623, 40167, 0},
      {46509, 40167, 0},
      {44395, 40167, 0},
      {42281, 40167, 0},
      {40167, 40167, 0},
      {38053, 40167, 0},
      {35939, 40167, 0},
      {33825, 40167, 0},
      {31710, 40167, 0},
      {29596, 40167, 0},
      {27482, 40167, 0},
      {25368, 40167, 0},
      {23254, 40167, 2114},
      {21140, 40167, 4228},
      {19026, 40167, 6342},
      {16912, 40167, 8456},
      {14798, 40167, 10570},
      {12684, 40167, 12684},
      {10570, 40167, 14798},
      {8456, 40167, 16912},
      {6342, 40167, 19026},
      {4228, 40167, 21140},
      {2114, 40167, 23254},
      {0, 40167, 25368}
    ],
    [
      {65535, 38053, 0},
      {63421, 38053, 0},
      {61307, 38053, 0},
      {59193, 38053, 0},
      {57079, 38053, 0},
      {54965, 38053, 0},
      {52851, 38053, 0},
      {50737, 38053, 0},
      {48623, 38053, 0},
      {46509, 38053, 0},
      {44395, 38053, 0},
      {42281, 38053, 0},
      {40167, 38053, 0},
      {38053, 38053, 0},
      {35939, 38053, 0},
      {33825, 38053, 0},
      {31710, 38053, 0},
      {29596, 38053, 0},
      {27482, 38053, 0},
      {25368, 38053, 2114},
      {23254, 38053, 4228},
      {21140, 38053, 6342},
      {19026, 38053, 8456},
      {16912, 38053, 10570},
      {14798, 38053, 12684},
      {12684, 38053, 14798},
      {10570, 38053, 16912},
      {8456, 38053, 19026},
      {6342, 38053, 21140},
      {4228, 38053, 23254},
      {2114, 38053, 25368},
      {0, 38053, 27482}
    ],
    [
      {65535, 35939, 0},
      {63421, 35939, 0},
      {61307, 35939, 0},
      {59193, 35939, 0},
      {57079, 35939, 0},
      {54965, 35939, 0},
      {52851, 35939, 0},
      {50737, 35939, 0},
      {48623, 35939, 0},
      {46509, 35939, 0},
      {44395, 35939, 0},
      {42281, 35939, 0},
      {40167, 35939, 0},
      {38053, 35939, 0},
      {35939, 35939, 0},
      {33825, 35939, 0},
      {31710, 35939, 0},
      {29596, 35939, 0},
      {27482, 35939, 2114},
      {25368, 35939, 4228},
      {23254, 35939, 6342},
      {21140, 35939, 8456},
      {19026, 35939, 10570},
      {16912, 35939, 12684},
      {14798, 35939, 14798},
      {12684, 35939, 16912},
      {10570, 35939, 19026},
      {8456, 35939, 21140},
      {6342, 35939, 23254},
      {4228, 35939, 25368},
      {2114, 35939, 27482},
      {0, 35939, 29596}
    ],
    [
      {65535, 33825, 0},
      {63421, 33825, 0},
      {61307, 33825, 0},
      {59193, 33825, 0},
      {57079, 33825, 0},
      {54965, 33825, 0},
      {52851, 33825, 0},
      {50737, 33825, 0},
      {48623, 33825, 0},
      {46509, 33825, 0},
      {44395, 33825, 0},
      {42281, 33825, 0},
      {40167, 33825, 0},
      {38053, 33825, 0},
      {35939, 33825, 0},
      {33825, 33825, 0},
      {31710, 33825, 0},
      {29596, 33825, 2114},
      {27482, 33825, 4228},
      {25368, 33825, 6342},
      {23254, 33825, 8456},
      {21140, 33825, 10570},
      {19026, 33825, 12684},
      {16912, 33825, 14798},
      {14798, 33825, 16912},
      {12684, 33825, 19026},
      {10570, 33825, 21140},
      {8456, 33825, 23254},
      {6342, 33825, 25368},
      {4228, 33825, 27482},
      {2114, 33825, 29596},
      {0, 33825, 31710}
    ],
    [
      {65535, 31710, 0},
      {63421, 31710, 0},
      {61307, 31710, 0},
      {59193, 31710, 0},
      {57079, 31710, 0},
      {54965, 31710, 0},
      {52851, 31710, 0},
      {50737, 31710, 0},
      {48623, 31710, 0},
      {46509, 31710, 0},
      {44395, 31710, 0},
      {42281, 31710, 0},
      {40167, 31710, 0},
      {38053, 31710, 0},
      {35939, 31710, 0},
      {33825, 31710, 0},
      {31710, 31710, 2114},
      {29596, 31710, 4228},
      {27482, 31710, 6342},
      {25368, 31710, 8456},
      {23254, 31710, 10570},
      {21140, 31710, 12684},
      {19026, 31710, 14798},
      {16912, 31710, 16912},
      {14798, 31710, 19026},
      {12684, 31710, 21140},
      {10570, 31710, 23254},
      {8456, 31710, 25368},
      {6342, 31710, 27482},
      {4228, 31710, 29596},
      {2114, 31710, 31710},
      {0, 31710, 33825}
    ],
    [
      {65535, 29596, 0},
      {63421, 29596, 0},
      {61307, 29596, 0},
      {59193, 29596, 0},
      {57079, 29596, 0},
      {54965, 29596, 0},
      {52851, 29596, 0},
      {50737, 29596, 0},
      {48623, 29596, 0},
      {46509, 29596, 0},
      {44395, 29596, 0},
      {42281, 29596, 0},
      {40167, 29596, 0},
      {38053, 29596, 0},
      {35939, 29596, 0},
      {33825, 29596, 2114},
      {31710, 29596, 4228},
      {29596, 29596, 6342},
      {27482, 29596, 8456},
      {25368, 29596, 10570},
      {23254, 29596, 12684},
      {21140, 29596, 14798},
      {19026, 29596, 16912},
      {16912, 29596, 19026},
      {14798, 29596, 21140},
      {12684, 29596, 23254},
      {10570, 29596, 25368},
      {8456, 29596, 27482},
      {6342, 29596, 29596},
      {4228, 29596, 31710},
      {2114, 29596, 33825},
      {0, 29596, 35939}
    ],
    [
      {65535, 27482, 0},
      {63421, 27482, 0},
      {61307, 27482, 0},
      {59193, 27482, 0},
      {57079, 27482, 0},
      {54965, 27482, 0},
      {52851, 27482, 0},
      {50737, 27482, 0},
      {48623, 27482, 0},
      {46509, 27482, 0},
      {44395, 27482, 0},
      {42281, 27482, 0},
      {40167, 27482, 0},
      {38053, 27482, 0},
      {35939, 27482, 2114},
      {33825, 27482, 4228},
      {31710, 27482, 6342},
      {29596, 27482, 8456},
      {27482, 27482, 10570},
      {25368, 27482, 12684},
      {23254, 27482, 14798},
      {21140, 27482, 16912},
      {19026, 27482, 19026},
      {16912, 27482, 21140},
      {14798, 27482, 23254},
      {12684, 27482, 25368},
      {10570, 27482, 27482},
      {8456, 27482, 29596},
      {6342, 27482, 31710},
      {4228, 27482, 33825},
      {2114, 27482, 35939},
      {0, 27482, 38053}
    ],
    [
      {65535, 25368, 0},
      {63421, 25368, 0},
      {61307, 25368, 0},
      {59193, 25368, 0},
      {57079, 25368, 0},
      {54965, 25368, 0},
      {52851, 25368, 0},
      {50737, 25368, 0},
      {48623, 25368, 0},
      {46509, 25368, 0},
      {44395, 25368, 0},
      {42281, 25368, 0},
      {40167, 25368, 0},
      {38053, 25368, 2114},
      {35939, 25368, 4228},
      {33825, 25368, 6342},
      {31710, 25368, 8456},
      {29596, 25368, 10570},
      {27482, 25368, 12684},
      {25368, 25368, 14798},
      {23254, 25368, 16912},
      {21140, 25368, 19026},
      {19026, 25368, 21140},
      {16912, 25368, 23254},
      {14798, 25368, 25368},
      {12684, 25368, 27482},
      {10570, 25368, 29596},
      {8456, 25368, 31710},
      {6342, 25368, 33825},
      {4228, 25368, 35939},
      {2114, 25368, 38053},
      {0, 25368, 40167}
    ],
    [
      {65535, 23254, 0},
      {63421, 23254, 0},
      {61307, 23254, 0},
      {59193, 23254, 0},
      {57079, 23254, 0},
      {54965, 23254, 0},
      {52851, 23254, 0},
      {50737, 23254, 0},
      {48623, 23254, 0},
      {46509, 23254, 0},
      {44395, 23254, 0},
      {42281, 23254, 0},
      {40167, 23254, 2114},
      {38053, 23254, 4228},
      {35939, 23254, 6342},
      {33825, 23254, 8456},
      {31710, 23254, 10570},
      {29596, 23254, 12684},
      {27482, 23254, 14798},
      {25368, 23254, 16912},
      {23254, 23254, 19026},
      {21140, 23254, 21140},
      {19026, 23254, 23254},
      {16912, 23254, 25368},
      {14798, 23254, 27482},
      {12684, 23254, 29596},
      {10570, 23254, 31710},
      {8456, 23254, 33825},
      {6342, 23254, 35939},
      {4228, 23254, 38053},
      {2114, 23254, 40167},
      {0, 23254, 42281}
    ],
    [
      {65535, 21140, 0},
      {63421, 21140, 0},
      {61307, 21140, 0},
      {59193, 21140, 0},
      {57079, 21140, 0},
      {54965, 21140, 0},
      {52851, 21140, 0},
      {50737, 21140, 0},
      {48623, 21140, 0},
      {46509, 21140, 0},
      {44395, 21140, 0},
      {42281, 21140, 2114},
      {40167, 21140, 4228},
      {38053, 21140, 6342},
      {35939, 21140, 8456},
      {33825, 21140, 10570},
      {31710, 21140, 12684},
      {29596, 21140, 14798},
      {27482, 21140, 16912},
      {25368, 21140, 19026},
      {23254, 21140, 21140},
      {21140, 21140, 23254},
      {19026, 21140, 25368},
      {16912, 21140, 27482},
      {14798, 21140, 29596},
      {12684, 21140, 31710},
      {10570, 21140, 33825},
      {8456, 21140, 35939},
      {6342, 21140, 38053},
      {4228, 21140, 40167},
      {2114, 21140, 42281},
      {0, 21140, 44395}
    ],
    [
      {65535, 19026, 0},
      {63421, 19026, 0},
      {61307, 19026, 0},
      {59193, 19026, 0},
      {57079, 19026, 0},
      {54965, 19026, 0},
      {52851, 19026, 0},
      {50737, 19026, 0},
      {48623, 19026, 0},
      {46509, 19026, 0},
      {44395, 19026, 2114},
      {42281, 19026, 4228},
      {40167, 19026, 6342},
      {38053, 19026, 8456},
      {35939, 19026, 10570},
      {33825, 19026, 12684},
      {31710, 19026, 14798},
      {29596, 19026, 16912},
      {27482, 19026, 19026},
      {25368, 19026, 21140},
      {23254, 19026, 23254},
      {21140, 19026, 25368},
      {19026, 19026, 27482},
      {16912, 19026, 29596},
      {14798, 19026, 31710},
      {12684, 19026, 33825},
      {10570, 19026, 35939},
      {8456, 19026, 38053},
      {6342, 19026, 40167},
      {4228, 19026, 42281},
      {2114, 19026, 44395},
      {0, 19026, 46509}
    ],
    [
      {65535, 16912, 0},
      {63421, 16912, 0},
      {61307, 16912, 0},
      {59193, 16912, 0},
      {57079, 16912, 0},
      {54965, 16912, 0},
      {52851, 16912, 0},
      {50737, 16912, 0},
      {48623, 16912, 0},
      {46509, 16912, 2114},
      {44395, 16912, 4228},
      {42281, 16912, 6342},
      {40167, 16912, 8456},
      {38053, 16912, 10570},
      {35939, 16912, 12684},
      {33825, 16912, 14798},
      {31710, 16912, 16912},
      {29596, 16912, 19026},
      {27482, 16912, 21140},
      {25368, 16912, 23254},
      {23254, 16912, 25368},
      {21140, 16912, 27482},
      {19026, 16912, 29596},
      {16912, 16912, 31710},
      {14798, 16912, 33825},
      {12684, 16912, 35939},
      {10570, 16912, 38053},
      {8456, 16912, 40167},
      {6342, 16912, 42281},
      {4228, 16912, 44395},
      {2114, 16912, 46509},
      {0, 16912, 48623}
    ],
    [
      {65535, 14798, 0},
      {63421, 14798, 0},
      {61307, 14798, 0},
      {59193, 14798, 0},
      {57079, 14798, 0},
      {54965, 14798, 0},
      {52851, 14798, 0},
      {50737, 14798, 0},
      {48623, 14798, 2114},
      {46509, 14798, 4228},
      {44395, 14798, 6342},
      {42281, 14798, 8456},
      {40167, 14798, 10570},
      {38053, 14798, 12684},
      {35939, 14798, 14798},
      {33825, 14798, 16912},
      {31710, 14798, 19026},
      {29596, 14798, 21140},
      {27482, 14798, 23254},
      {25368, 14798, 25368},
      {23254, 14798, 27482},
      {21140, 14798, 29596},
      {19026, 14798, 31710},
      {16912, 14798, 33825},
      {14798, 14798, 35939},
      {12684, 14798, 38053},
      {10570, 14798, 40167},
      {8456, 14798, 42281},
      {6342, 14798, 44395},
      {4228, 14798, 46509},
      {2114, 14798, 48623},
      {0, 14798, 50737}
    ],
    [
      {65535, 12684, 0},
      {63421, 12684, 0},
      {61307, 12684, 0},
      {59193, 12684, 0},
      {57079, 12684, 0},
      {54965, 12684, 0},
      {52851, 12684, 0},
      {50737, 12684, 2114},
      {48623, 12684, 4228},
      {46509, 12684, 6342},
      {44395, 12684, 8456},
      {42281, 12684, 10570},
      {40167, 12684, 12684},
      {38053, 12684, 14798},
      {35939, 12684, 16912},
      {33825, 12684, 19026},
      {31710, 12684, 21140},
      {29596, 12684, 23254},
      {27482, 12684, 25368},
      {25368, 12684, 27482},
      {23254, 12684, 29596},
      {21140, 12684, 31710},
      {19026, 12684, 33825},
      {16912, 12684, 35939},
      {14798, 12684, 38053},
      {12684, 12684, 40167},
      {10570, 12684, 42281},
      {8456, 12684, 44395},
      {6342, 12684, 46509},
      {4228, 12684, 48623},
      {2114, 12684, 50737},
      {0, 12684, 52851}
    ],
    [
      {65535, 10570, 0},
      {63421, 10570, 0},
      {61307, 10570, 0},
      {59193, 10570, 0},
      {57079, 10570, 0},
      {54965, 10570, 0},
      {52851, 10570, 2114},
      {50737, 10570, 4228},
      {48623, 10570, 6342},
      {46509, 10570, 8456},
      {44395, 10570, 10570},
      {42281, 10570, 12684},
      {40167, 10570, 14798},
      {38053, 10570, 16912},
      {35939, 10570, 19026},
      {33825, 10570, 21140},
      {31710, 10570, 23254},
      {29596, 10570, 25368},
      {27482, 10570, 27482},
      {25368, 10570, 29596},
      {23254, 10570, 31710},
      {21140, 10570, 33825},
      {19026, 10570, 35939},
      {16912, 10570, 38053},
      {14798, 10570, 40167},
      {12684, 10570, 42281},
      {10570, 10570, 44395},
      {8456, 10570, 46509},
      {6342, 10570, 48623},
      {4228, 10570, 50737},
      {2114, 10570, 52851},
      {0, 10570, 54965}
    ],
    [
      {65535, 8456, 0},
      {63421, 8456, 0},
      {61307, 8456, 0},
      {59193, 8456, 0},
      {57079, 8456, 0},
      {54965, 8456, 2114},
      {52851, 8456, 4228},
      {50737, 8456, 6342},
      {48623, 8456, 8456},
      {46509, 8456, 10570},
      {44395, 8456, 12684},
      {42281, 8456, 14798},
      {40167, 8456, 16912},
      {38053, 8456, 19026},
      {35939, 8456, 21140},
      {33825, 8456, 23254},
      {31710, 8456, 25368},
      {29596, 8456, 27482},
      {27482, 8456, 29596},
      {25368, 8456, 31710},
      {23254, 8456, 33825},
      {21140, 8456, 35939},
      {19026, 8456, 38053},
      {16912, 8456, 40167},
      {14798, 8456, 42281},
      {12684, 8456, 44395},
      {10570, 8456, 46509},
      {8456, 8456, 48623},
      {6342, 8456, 50737},
      {4228, 8456, 52851},
      {2114, 8456, 54965},
      {0, 8456, 57079}
    ],
    [
      {65535, 6342, 0},
      {63421, 6342, 0},
      {61307, 6342, 0},
      {59193, 6342, 0},
      {57079, 6342, 2114},
      {54965, 6342, 4228},
      {52851, 6342, 6342},
      {50737, 6342, 8456},
      {48623, 6342, 10570},
      {46509, 6342, 12684},
      {44395, 6342, 14798},
      {42281, 6342, 16912},
      {40167, 6342, 19026},
      {38053, 6342, 21140},
      {35939, 6342, 23254},
      {33825, 6342, 25368},
      {31710, 6342, 27482},
      {29596, 6342, 29596},
      {27482, 6342, 31710},
      {25368, 6342, 33825},
      {23254, 6342, 35939},
      {21140, 6342, 38053},
      {19026, 6342, 40167},
      {16912, 6342, 42281},
      {14798, 6342, 44395},
      {12684, 6342, 46509},
      {10570, 6342, 48623},
      {8456, 6342, 50737},
      {6342, 6342, 52851},
      {4228, 6342, 54965},
      {2114, 6342, 57079},
      {0, 6342, 59193}
    ],
    [
      {65535, 4228, 0},
      {63421, 4228, 0},
      {61307, 4228, 0},
      {59193, 4228, 2114},
      {57079, 4228, 4228},
      {54965, 4228, 6342},
      {52851, 4228, 8456},
      {50737, 4228, 10570},
      {48623, 4228, 12684},
      {46509, 4228, 14798},
      {44395, 4228, 16912},
      {42281, 4228, 19026},
      {40167, 4228, 21140},
      {38053, 4228, 23254},
      {35939, 4228, 25368},
      {33825, 4228, 27482},
      {31710, 4228, 29596},
      {29596, 4228, 31710},
      {27482, 4228, 33825},
      {25368, 4228, 35939},
      {23254, 4228, 38053},
      {21140, 4228, 40167},
      {19026, 4228, 42281},
      {16912, 4228, 44395},
      {14798, 4228, 46509},
      {12684, 4228, 48623},
      {10570, 4228, 50737},
      {8456, 4228, 52851},
      {6342, 4228, 54965},
      {4228, 4228, 57079},
      {2114, 4228, 59193},
      {0, 4228, 61307}
    ],
    [
      {65535, 2114, 0},
      {63421, 2114, 0},
      {61307, 2114, 2114},
      {59193, 2114, 4228},
      {57079, 2114, 6342},
      {54965, 2114, 8456},
      {52851, 2114, 10570},
      {50737, 2114, 12684},
      {48623, 2114, 14798},
      {46509, 2114, 16912},
      {44395, 2114, 19026},
      {42281, 2114, 21140},
      {40167, 2114, 23254},
      {38053, 2114, 25368},
      {35939, 2114, 27482},
      {33825, 2114, 29596},
      {31710, 2114, 31710},
      {29596, 2114, 33825},
      {27482, 2114, 35939},
      {25368, 2114, 38053},
      {23254, 2114, 40167},
      {21140, 2114, 42281},
      {19026, 2114, 44395},
      {16912, 2114, 46509},
      {14798, 2114, 48623},
      {12684, 2114, 50737},
      {10570, 2114, 52851},
      {8456, 2114, 54965},
      {6342, 2114, 57079},
      {4228, 2114, 59193},
      {2114, 2114, 61307},
      {0, 2114, 63421}
    ],
    [
      {65535, 0, 0},
      {63421, 0, 2114},
      {61307, 0, 4228},
      {59193, 0, 6342},
      {57079, 0, 8456},
      {54965, 0, 10570},
      {52851, 0, 12684},
      {50737, 0, 14798},
      {48623, 0, 16912},
      {46509, 0, 19026},
      {44395, 0, 21140},
      {42281, 0, 23254},
      {40167, 0, 25368},
      {38053, 0, 27482},
      {35939, 0, 29596},
      {33825, 0, 31710},
      {31710, 0, 33825},
      {29596, 0, 35939},
      {27482, 0, 38053},
      {25368, 0, 40167},
      {23254, 0, 42281},
      {21140, 0, 44395},
      {19026, 0, 46509},
      {16912, 0, 48623},
      {14798, 0, 50737},
      {12684, 0, 52851},
      {10570, 0, 54965},
      {8456, 0, 57079},
      {6342, 0, 59193},
      {4228, 0, 61307},
      {2114, 0, 63421},
      {0, 0, 65535}
    ]
  ]
  test "16 bit rgb" do
    {:ok, image} = Imagineer.load(@test_path <> "basn2c16.png")

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

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

    assert_pixels_match(image.pixels, @actual_pixels)

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

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

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

    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
