public function writeTransparency(PngPalette $palette) 
    {
        if ($palette && $palette->isValid && $palette->hasAlphaChannel) {
            $this->buffer->startChunk("tRNS");
            
            $alpha = '';

            foreach ($palette->colors as $color) {
                $alpha .= pack('C', $color & 0xff);
            }
            
            $this->buffer->writeString($alpha);

            $this->buffer->endChunk();
        }
    }