public function writeTrueColorWithAlpha(
        array & $colorRanges, $width, $height) 
    {
        $this->buffer->startChunk("IDAT");

        $uncompressed = '';
        $count = -1;
        $x = 0;
        
        foreach ($colorRanges as $value) {
            if ($count === -1) {
                $count = $value;
            } else {
                if ($count !== 0) {
                    if ($x === $width) {
                        $x = 0;
                    }
                    if ($x === 0) {
                        $uncompressed .= pack('C', 0); // No filtering
                    }
                    
                    $uncompressed .= str_repeat(pack('N', $value), $count);
                    $x += $count;
                }
                
                $count = -1;
            }
        }

        $compressed = gzcompress($uncompressed, 2);
        $this->buffer->writeString($compressed);

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