Palette images store an index per pixel and look up the real color in a PLTE table. Today you add palette assembly, which means reading the PLTE chunk and indexing it.
Assemble color type 3 (palette) images by looking each pixel's index up in the PLTE chunk.
Palette images (color type 3) do not store colors per pixel - they store a small index per pixel and keep the actual colors in the PLTE chunk, a flat list of RGB triples. Assembly is a lookup: read the index, fetch palette[index], and write its three bytes with opaque alpha. With a two-entry palette and indices 0,1,1,0, the four pixels alternate between the two palette colors. This indirection is how PNG keeps images with few distinct colors tiny.
Parsing PLTE is trivial - three bytes per entry, so its data length divided by three is the entry count - but two guards matter. An index that points past the end of the palette is a malformed file and should error rather than read out of bounds, and a type-3 image with no PLTE chunk at all is invalid. Palette entries carry only RGB; per-index transparency lives in a separate optional tRNS chunk this teaching codec leaves opaque. With palette done, every 8-bit color type is handled - only the bit-depth variations remain.
// parse PLTE data into [][3]byte entries (3 bytes each).// case 3: idx := raw[i]; e := palette[idx]; Set(x,y, e[0],e[1],e[2], 255)func parsePLTE(data []byte) [][3]byte { }