File manager - Edit - /home/opticamezl/www/newok/Color.tar
Back
ColorConverter.php 0000604 00000021620 15176011035 0010217 0 ustar 00 <?php namespace Mpdf\Color; use Mpdf\Mpdf; class ColorConverter { const MODE_GRAYSCALE = 1; const MODE_SPOT = 2; const MODE_RGB = 3; const MODE_CMYK = 4; const MODE_RGBA = 5; const MODE_CMYKA = 6; private $mpdf; private $colorModeConverter; private $colorSpaceRestrictor; private $cache; public function __construct(Mpdf $mpdf, ColorModeConverter $colorModeConverter, ColorSpaceRestrictor $colorSpaceRestrictor) { $this->mpdf = $mpdf; $this->colorModeConverter = $colorModeConverter; $this->colorSpaceRestrictor = $colorSpaceRestrictor; $this->cache = []; } public function convert($color, array &$PDFAXwarnings = []) { $color = trim(strtolower($color)); $cstr = ''; if ($color == 'transparent') { return false; } elseif ($color == 'inherit') { return false; } elseif (isset(NamedColors::$colors[$color])) { $color = NamedColors::$colors[$color]; } if (!isset($this->cache[$color])) { $c = $this->convertPlain($color, $PDFAXwarnings); if (is_array($c)) { $c = array_pad($c, 6, 0); $cstr = pack("a1ccccc", $c[0], ($c[1] & 0xFF), ($c[2] & 0xFF), ($c[3] & 0xFF), ($c[4] & 0xFF), ($c[5] & 0xFF)); } $this->cache[$color] = $cstr; } return $this->cache[$color]; } public function lighten($c) { $this->ensureBinaryColorFormat($c); if ($c{0} == static::MODE_RGB || $c{0} == static::MODE_RGBA) { list($h, $s, $l) = $this->colorModeConverter->rgb2hsl(ord($c{1}) / 255, ord($c{2}) / 255, ord($c{3}) / 255); $l += ((1 - $l) * 0.8); list($r, $g, $b) = $this->colorModeConverter->hsl2rgb($h, $s, $l); $ret = [3, $r, $g, $b]; } elseif ($c{0} == static::MODE_CMYK || $c{0} == static::MODE_CMYKA) { $ret = [4, max(0, (ord($c{1}) - 20)), max(0, (ord($c{2}) - 20)), max(0, (ord($c{3}) - 20)), max(0, (ord($c{4}) - 20))]; } elseif ($c{0} == static::MODE_GRAYSCALE) { $ret = [1, min(255, (ord($c{1}) + 32))]; } $c = array_pad($ret, 6, 0); $cstr = pack("a1ccccc", $c[0], ($c[1] & 0xFF), ($c[2] & 0xFF), ($c[3] & 0xFF), ($c[4] & 0xFF), ($c[5] & 0xFF)); return $cstr; } public function darken($c) { $this->ensureBinaryColorFormat($c); if ($c{0} == static::MODE_RGB || $c{0} == static::MODE_RGBA) { list($h, $s, $l) = $this->colorModeConverter->rgb2hsl(ord($c{1}) / 255, ord($c{2}) / 255, ord($c{3}) / 255); $s *= 0.25; $l *= 0.75; list($r, $g, $b) = $this->colorModeConverter->hsl2rgb($h, $s, $l); $ret = [3, $r, $g, $b]; } elseif ($c{0} == static::MODE_CMYK || $c{0} == static::MODE_CMYKA) { $ret = [4, min(100, (ord($c{1}) + 20)), min(100, (ord($c{2}) + 20)), min(100, (ord($c{3}) + 20)), min(100, (ord($c{4}) + 20))]; } elseif ($c{0} == static::MODE_GRAYSCALE) { $ret = [1, max(0, (ord($c{1}) - 32))]; } $c = array_pad($ret, 6, 0); $cstr = pack("a1ccccc", $c[0], ($c[1] & 0xFF), ($c[2] & 0xFF), ($c[3] & 0xFF), ($c[4] & 0xFF), ($c[5] & 0xFF)); return $cstr; } /** * @param string $c * * @return float[] */ public function invert($c) { $this->ensureBinaryColorFormat($c); if ($c{0} == static::MODE_RGB || $c{0} == static::MODE_RGBA) { return [3, (255 - ord($c{1})), (255 - ord($c{2})), (255 - ord($c{3}))]; } elseif ($c{0} == static::MODE_CMYK || $c{0} == static::MODE_CMYKA) { return [4, (100 - ord($c{1})), (100 - ord($c{2})), (100 - ord($c{3})), (100 - ord($c{4}))]; } elseif ($c{0} == static::MODE_GRAYSCALE) { return [1, (255 - ord($c{1}))]; } // Cannot cope with non-RGB colors at present throw new \Mpdf\MpdfException('Trying to invert non-RGB color'); } /** * @param string $c Binary color string * * @return string */ public function colAtoString($c) { $s = ''; if ($c{0} == static::MODE_GRAYSCALE) { $s = 'rgb(' . ord($c{1}) . ', ' . ord($c{1}) . ', ' . ord($c{1}) . ')'; } elseif ($c{0} == static::MODE_SPOT) { $s = 'spot(' . ord($c{1}) . ', ' . ord($c{2}) . ')'; } elseif ($c{0} == static::MODE_RGB) { $s = 'rgb(' . ord($c{1}) . ', ' . ord($c{2}) . ', ' . ord($c{3}) . ')'; } elseif ($c{0} == static::MODE_CMYK) { $s = 'cmyk(' . ord($c{1}) . ', ' . ord($c{2}) . ', ' . ord($c{3}) . ', ' . ord($c{4}) . ')'; } elseif ($c{0} == static::MODE_RGBA) { $s = 'rgba(' . ord($c{1}) . ', ' . ord($c{2}) . ', ' . ord($c{3}) . ', ' . sprintf('%0.2F', ord($c{4}) / 100) . ')'; } elseif ($c{0} == static::MODE_CMYKA) { $s = 'cmyka(' . ord($c{1}) . ', ' . ord($c{2}) . ', ' . ord($c{3}) . ', ' . ord($c{4}) . ', ' . sprintf('%0.2F', ord($c{5}) / 100) . ')'; } return $s; } /** * @param string $color * @param string[] $PDFAXwarnings * * @return bool|float[] */ private function convertPlain($color, array &$PDFAXwarnings = []) { $c = false; if (preg_match('/^[\d]+$/', $color)) { $c = ([static::MODE_GRAYSCALE, $color]); // i.e. integer only } elseif (strpos($color, '#') === 0) { // case of #nnnnnn or #nnn $c = $this->processHashColor($color); } elseif (preg_match('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\((.*?)\)/', $color, $m)) { $c = $this->processModeColor($m[1], explode(',', $m[2])); } if ($this->mpdf->PDFA || $this->mpdf->PDFX || $this->mpdf->restrictColorSpace) { $c = $this->restrictColorSpace($c, $color, $PDFAXwarnings); } return $c; } /** * @param string $color * * @return float[] */ private function processHashColor($color) { // in case of Background: #CCC url() x-repeat etc. $cor = preg_replace('/\s+.*/', '', $color); // Turn #RGB into #RRGGBB if (strlen($cor) == 4) { $cor = "#" . $cor[1] . $cor[1] . $cor[2] . $cor[2] . $cor[3] . $cor[3]; } $r = hexdec(substr($cor, 1, 2)); $g = hexdec(substr($cor, 3, 2)); $b = hexdec(substr($cor, 5, 2)); return [3, $r, $g, $b]; } /** * @param $mode * @param mixed[] $cores * * @return bool|\float[] */ private function processModeColor($mode, array $cores) { $c = false; $cores = $this->convertPercentCoreValues($mode, $cores); switch ($mode) { case 'rgb': return [static::MODE_RGB, $cores[0], $cores[1], $cores[2]]; case 'rgba': return [static::MODE_RGBA, $cores[0], $cores[1], $cores[2], $cores[3] * 100]; case 'cmyk': case 'device-cmyk': return [static::MODE_CMYK, $cores[0], $cores[1], $cores[2], $cores[3]]; case 'cmyka': case 'device-cmyka': return [static::MODE_CMYKA, $cores[0], $cores[1], $cores[2], $cores[3], $cores[4] * 100]; case 'hsl': $conv = $this->colorModeConverter->hsl2rgb($cores[0] / 360, $cores[1], $cores[2]); return [static::MODE_RGB, $conv[0], $conv[1], $conv[2]]; case 'hsla': $conv = $this->colorModeConverter->hsl2rgb($cores[0] / 360, $cores[1], $cores[2]); return [static::MODE_RGBA, $conv[0], $conv[1], $conv[2], $cores[3] * 100]; case 'spot': $name = strtoupper(trim($cores[0])); if (!isset($this->mpdf->spotColors[$name])) { if (isset($cores[5])) { $this->mpdf->AddSpotColor($cores[0], $cores[2], $cores[3], $cores[4], $cores[5]); } else { throw new \Mpdf\MpdfException(sprintf('Undefined spot color "%s"', $name)); } } return [static::MODE_SPOT, $this->mpdf->spotColors[$name]['i'], $cores[1]]; } return $c; } /** * @param string $mode * @param mixed[] $cores * * @return float[] */ private function convertPercentCoreValues($mode, array $cores) { $ncores = count($cores); if (strpos($cores[0], '%') !== false) { $cores[0] = (float) $cores[0]; if ($mode === 'rgb' || $mode === 'rgba') { $cores[0] = (int) ($cores[0] * 255 / 100); } } if ($ncores > 1 && strpos($cores[1], '%') !== false) { $cores[1] = (float) $cores[1]; if ($mode === 'rgb' || $mode === 'rgba') { $cores[1] = (int) ($cores[1] * 255 / 100); } if ($mode === 'hsl' || $mode === 'hsla') { $cores[1] = $cores[1] / 100; } } if ($ncores > 2 && strpos($cores[2], '%') !== false) { $cores[2] = (float) $cores[2]; if ($mode === 'rgb' || $mode === 'rgba') { $cores[2] = (int) ($cores[2] * 255 / 100); } if ($mode === 'hsl' || $mode === 'hsla') { $cores[2] = $cores[2] / 100; } } if ($ncores > 3 && strpos($cores[3], '%') !== false) { $cores[3] = (float) $cores[3]; } return $cores; } /** * @param mixed $c * @param string $color * @param string[] $PDFAXwarnings * * @return float[] */ private function restrictColorSpace($c, $color, &$PDFAXwarnings = []) { return $this->colorSpaceRestrictor->restrictColorSpace($c, $color, $PDFAXwarnings); } /** * @param string $color Binary color string */ private function ensureBinaryColorFormat($color) { if (!is_string($color)) { throw new \Mpdf\MpdfException('Invalid color input, binary color string expected'); } if (strlen($color) !== 6) { throw new \Mpdf\MpdfException('Invalid color input, binary color string expected'); } if (!in_array($color[0], [static::MODE_GRAYSCALE, static::MODE_SPOT, static::MODE_RGB, static::MODE_CMYK, static::MODE_RGBA, static::MODE_CMYKA])) { throw new \Mpdf\MpdfException('Invalid color input, invalid color mode in binary color string'); } } } NamedColors.php 0000604 00000010166 15176011035 0007462 0 ustar 00 <?php namespace Mpdf\Color; class NamedColors { public static $colors = [ 'aliceblue' => '#f0f8ff', 'antiquewhite' => '#faebd7', 'aqua' => '#00ffff', 'aquamarine' => '#7fffd4', 'azure' => '#f0ffff', 'beige' => '#f5f5dc', 'bisque' => '#ffe4c4', 'black' => '#000000', 'blanchedalmond' => '#ffebcd', 'blue' => '#0000ff', 'blueviolet' => '#8a2be2', 'brown' => '#a52a2a', 'burlywood' => '#deb887', 'cadetblue' => '#5f9ea0', 'chartreuse' => '#7fff00', 'chocolate' => '#d2691e', 'coral' => '#ff7f50', 'cornflowerblue' => '#6495ed', 'cornsilk' => '#fff8dc', 'crimson' => '#dc143c', 'cyan' => '#00ffff', 'darkblue' => '#00008b', 'darkcyan' => '#008b8b', 'darkgoldenrod' => '#b8860b', 'darkgray' => '#a9a9a9', 'darkgreen' => '#006400', 'darkgrey' => '#a9a9a9', 'darkkhaki' => '#bdb76b', 'darkmagenta' => '#8b008b', 'darkolivegreen' => '#556b2f', 'darkorange' => '#ff8c00', 'darkorchid' => '#9932cc', 'darkred' => '#8b0000', 'darksalmon' => '#e9967a', 'darkseagreen' => '#8fbc8f', 'darkslateblue' => '#483d8b', 'darkslategray' => '#2f4f4f', 'darkslategrey' => '#2f4f4f', 'darkturquoise' => '#00ced1', 'darkviolet' => '#9400d3', 'deeppink' => '#ff1493', 'deepskyblue' => '#00bfff', 'dimgray' => '#696969', 'dimgrey' => '#696969', 'dodgerblue' => '#1e90ff', 'firebrick' => '#b22222', 'floralwhite' => '#fffaf0', 'forestgreen' => '#228b22', 'fuchsia' => '#ff00ff', 'gainsboro' => '#dcdcdc', 'ghostwhite' => '#f8f8ff', 'gold' => '#ffd700', 'goldenrod' => '#daa520', 'gray' => '#808080', 'green' => '#008000', 'greenyellow' => '#adff2f', 'grey' => '#808080', 'honeydew' => '#f0fff0', 'hotpink' => '#ff69b4', 'indianred' => '#cd5c5c', 'indigo' => '#4b0082', 'ivory' => '#fffff0', 'khaki' => '#f0e68c', 'lavender' => '#e6e6fa', 'lavenderblush' => '#fff0f5', 'lawngreen' => '#7cfc00', 'lemonchiffon' => '#fffacd', 'lightblue' => '#add8e6', 'lightcoral' => '#f08080', 'lightcyan' => '#e0ffff', 'lightgoldenrodyellow' => '#fafad2', 'lightgray' => '#d3d3d3', 'lightgreen' => '#90ee90', 'lightgrey' => '#d3d3d3', 'lightpink' => '#ffb6c1', 'lightsalmon' => '#ffa07a', 'lightseagreen' => '#20b2aa', 'lightskyblue' => '#87cefa', 'lightslategray' => '#778899', 'lightslategrey' => '#778899', 'lightsteelblue' => '#b0c4de', 'lightyellow' => '#ffffe0', 'lime' => '#00ff00', 'limegreen' => '#32cd32', 'linen' => '#faf0e6', 'magenta' => '#ff00ff', 'maroon' => '#800000', 'mediumaquamarine' => '#66cdaa', 'mediumblue' => '#0000cd', 'mediumorchid' => '#ba55d3', 'mediumpurple' => '#9370db', 'mediumseagreen' => '#3cb371', 'mediumslateblue' => '#7b68ee', 'mediumspringgreen' => '#00fa9a', 'mediumturquoise' => '#48d1cc', 'mediumvioletred' => '#c71585', 'midnightblue' => '#191970', 'mintcream' => '#f5fffa', 'mistyrose' => '#ffe4e1', 'moccasin' => '#ffe4b5', 'navajowhite' => '#ffdead', 'navy' => '#000080', 'oldlace' => '#fdf5e6', 'olive' => '#808000', 'olivedrab' => '#6b8e23', 'orange' => '#ffa500', 'orangered' => '#ff4500', 'orchid' => '#da70d6', 'palegoldenrod' => '#eee8aa', 'palegreen' => '#98fb98', 'paleturquoise' => '#afeeee', 'palevioletred' => '#d87093', 'papayawhip' => '#ffefd5', 'peachpuff' => '#ffdab9', 'peru' => '#cd853f', 'pink' => '#ffc0cb', 'plum' => '#dda0dd', 'powderblue' => '#b0e0e6', 'purple' => '#800080', 'red' => '#ff0000', 'rosybrown' => '#bc8f8f', 'royalblue' => '#4169e1', 'saddlebrown' => '#8b4513', 'salmon' => '#fa8072', 'sandybrown' => '#f4a460', 'seagreen' => '#2e8b57', 'seashell' => '#fff5ee', 'sienna' => '#a0522d', 'silver' => '#c0c0c0', 'skyblue' => '#87ceeb', 'slateblue' => '#6a5acd', 'slategray' => '#708090', 'slategrey' => '#708090', 'snow' => '#fffafa', 'springgreen' => '#00ff7f', 'steelblue' => '#4682b4', 'tan' => '#d2b48c', 'teal' => '#008080', 'thistle' => '#d8bfd8', 'tomato' => '#ff6347', 'turquoise' => '#40e0d0', 'violet' => '#ee82ee', 'violetred' => '#d02090', 'wheat' => '#f5deb3', 'white' => '#ffffff', 'whitesmoke' => '#f5f5f5', 'yellow' => '#ffff00', 'yellowgreen' => '#9acd32', ]; } ColorModeConverter.php 0000604 00000007206 15176011035 0011030 0 ustar 00 <?php namespace Mpdf\Color; class ColorModeConverter { /** * @param float[] $c * * @return float[] */ public function rgb2gray($c) { if (isset($c[4])) { return [1, (($c[1] * .21) + ($c[2] * .71) + ($c[3] * .07)), ord(1), $c[4]]; } else { return [1, (($c[1] * .21) + ($c[2] * .71) + ($c[3] * .07))]; } } /** * @param float[] $c * * @return float[] */ public function cmyk2gray($c) { $rgb = $this->cmyk2rgb($c); return $this->rgb2gray($rgb); } /** * @param float[] $c * * @return float[] */ public function rgb2cmyk($c) { $cyan = 1 - ($c[1] / 255); $magenta = 1 - ($c[2] / 255); $yellow = 1 - ($c[3] / 255); $min = min($cyan, $magenta, $yellow); if ($min == 1) { if ($c[0] == 5) { return [6, 100, 100, 100, 100, $c[4]]; } else { return [4, 100, 100, 100, 100]; } // For K-Black //if ($c[0]==5) { return array (6,0,0,0,100, $c[4]); } //else { return array (4,0,0,0,100); } } $K = $min; $black = 1 - $K; if ($c[0] == 5) { return [6, ($cyan - $K) * 100 / $black, ($magenta - $K) * 100 / $black, ($yellow - $K) * 100 / $black, $K * 100, $c[4]]; } else { return [4, ($cyan - $K) * 100 / $black, ($magenta - $K) * 100 / $black, ($yellow - $K) * 100 / $black, $K * 100]; } } /** * @param float[] $c * * @return float[] */ public function cmyk2rgb($c) { $rgb = []; $colors = 255 - ($c[4] * 2.55); $rgb[0] = intval($colors * (255 - ($c[1] * 2.55)) / 255); $rgb[1] = intval($colors * (255 - ($c[2] * 2.55)) / 255); $rgb[2] = intval($colors * (255 - ($c[3] * 2.55)) / 255); if ($c[0] == 6) { return [5, $rgb[0], $rgb[1], $rgb[2], $c[5]]; } else { return [3, $rgb[0], $rgb[1], $rgb[2]]; } } /** * @param float $r * @param float $g * @param float $b * * @return float[] */ public function rgb2hsl($r, $g, $b) { $h = 0; $min = min($r, $g, $b); $max = max($r, $g, $b); $diff = $max - $min; $l = ($max + $min) / 2; if ($diff == 0) { $h = 0; $s = 0; } else { if ($l < 0.5) { $s = $diff / ($max + $min); } else { $s = $diff / (2 - $max - $min); } $rDiff = ((($max - $r) / 6) + ($diff / 2)) / $diff; $gDiff = ((($max - $g) / 6) + ($diff / 2)) / $diff; $bDiff = ((($max - $b) / 6) + ($diff / 2)) / $diff; if ($r == $max) { $h = $bDiff - $gDiff; } elseif ($g == $max) { $h = (1 / 3) + $rDiff - $bDiff; } elseif ($b == $max) { $h = (2 / 3) + $gDiff - $rDiff; }; if ($h < 0) { $h += 1; } if ($h > 1) { $h -= 1; } } return [$h, $s, $l]; } /** * Input is HSL value of complementary colour, held in $h2, $s, $l as fractions of 1 * Output is RGB in normal 255 255 255 format, held in $r, $g, $b * * @param float $h * @param float $s * @param float $l * * @return float[] */ public function hsl2rgb($h, $s, $l) { if ($s == 0) { $r = $l * 255; $g = $l * 255; $b = $l * 255; } else { if ($l < 0.5) { $tmp = $l * (1 + $s); } else { $tmp = ($l + $s) - ($s * $l); } $tmp2 = 2 * $l - $tmp; $r = round(255 * $this->hue2rgb($tmp2, $tmp, $h + (1 / 3))); $g = round(255 * $this->hue2rgb($tmp2, $tmp, $h)); $b = round(255 * $this->hue2rgb($tmp2, $tmp, $h - (1 / 3))); } return [$r, $g, $b]; } /** * @param float $v1 * @param float $v2 * @param float $vh * * @return float */ public function hue2rgb($v1, $v2, $vh) { if ($vh < 0) { $vh += 1; }; if ($vh > 1) { $vh -= 1; }; if ((6 * $vh) < 1) { return ($v1 + ($v2 - $v1) * 6 * $vh); }; if ((2 * $vh) < 1) { return ($v2); }; if ((3 * $vh) < 2) { return ($v1 + ($v2 - $v1) * ((2 / 3 - $vh) * 6)); }; return $v1; } } ColorSpaceRestrictor.php 0000604 00000013612 15176011035 0011366 0 ustar 00 <?php namespace Mpdf\Color; use Mpdf\Mpdf; class ColorSpaceRestrictor { const RESTRICT_TO_GRAYSCALE = 1; const RESTRICT_TO_RGB_SPOT_GRAYSCALE = 2; const RESTRICT_TO_CMYK_SPOT_GRAYSCALE = 3; /** * @var \Mpdf\Mpdf */ private $mpdf; /** * @var \Mpdf\Color\ColorModeConverter */ private $colorModeConverter; /** * @var int */ private $mode; /** * Process $mode settings * 1 - allow GRAYSCALE only [convert CMYK/RGB->gray] * 2 - allow RGB / SPOT COLOR / Grayscale [convert CMYK->RGB] * 3 - allow CMYK / SPOT COLOR / Grayscale [convert RGB->CMYK] * * @param \Mpdf\Mpdf $mpdf * @param \Mpdf\Color\ColorModeConverter $colorModeConverter * @param int $mode */ public function __construct(Mpdf $mpdf, ColorModeConverter $colorModeConverter, $mode) { $this->mpdf = $mpdf; $this->colorModeConverter = $colorModeConverter; $this->mode = $mode; } /** * @param mixed $c * @param string $color * @param string[] $PDFAXwarnings * * @return float[] */ public function restrictColorSpace($c, $color, &$PDFAXwarnings = []) { $mode = (int) $c[0]; switch ($mode) { case 1: return $c; case 2: return $this->restrictSpotColorSpace($c, $PDFAXwarnings); case 3: return $this->restrictRgbColorSpace($c, $color, $PDFAXwarnings); case 4: return $this->restrictCmykColorSpace($c, $color, $PDFAXwarnings); case 5: return $this->restrictRgbaColorSpace($c, $color, $PDFAXwarnings); case 6: return $this->restrictCmykaColorSpace($c, $color, $PDFAXwarnings); } return $c; } /** * @param string $c * @param string[] $PDFAXwarnings * * @return float[] */ private function restrictSpotColorSpace($c, &$PDFAXwarnings = []) { if (!isset($this->mpdf->spotColorIDs[$c[1]])) { throw new \Mpdf\MpdfException('Error: Spot colour has not been defined - ' . $this->mpdf->spotColorIDs[$c[1]]); } if ($this->mpdf->PDFA) { if ($this->mpdf->PDFA && !$this->mpdf->PDFAauto) { $PDFAXwarnings[] = "Spot color specified '" . $this->mpdf->spotColorIDs[$c[1]] . "' (converted to process color)"; } if ($this->mode != 3) { $sp = $this->mpdf->spotColors[$this->mpdf->spotColorIDs[$c[1]]]; $c = $this->colorModeConverter->cmyk2rgb([4, $sp['c'], $sp['m'], $sp['y'], $sp['k']]); } } elseif ($this->mode == 1) { $sp = $this->mpdf->spotColors[$this->mpdf->spotColorIDs[$c[1]]]; $c = $this->colorModeConverter->cmyk2gray([4, $sp['c'], $sp['m'], $sp['y'], $sp['k']]); } return $c; } /** * @param mixed $c * @param string $color * @param string[] $PDFAXwarnings * * @return float[] */ private function restrictRgbColorSpace($c, $color, &$PDFAXwarnings = []) { if ($this->mpdf->PDFX || ($this->mpdf->PDFA && $this->mode == 3)) { if (($this->mpdf->PDFA && !$this->mpdf->PDFAauto) || ($this->mpdf->PDFX && !$this->mpdf->PDFXauto)) { $PDFAXwarnings[] = "RGB color specified '" . $color . "' (converted to CMYK)"; } $c = $this->colorModeConverter->rgb2cmyk($c); } elseif ($this->mode == 1) { $c = $this->colorModeConverter->rgb2gray($c); } elseif ($this->mode == 3) { $c = $this->colorModeConverter->rgb2cmyk($c); } return $c; } /** * @param mixed $c * @param string $color * @param string[] $PDFAXwarnings * * @return float[] */ private function restrictCmykColorSpace($c, $color, &$PDFAXwarnings = []) { if ($this->mpdf->PDFA && $this->mode != 3) { if ($this->mpdf->PDFA && !$this->mpdf->PDFAauto) { $PDFAXwarnings[] = "CMYK color specified '" . $color . "' (converted to RGB)"; } $c = $this->colorModeConverter->cmyk2rgb($c); } elseif ($this->mode == 1) { $c = $this->colorModeConverter->cmyk2gray($c); } elseif ($this->mode == 2) { $c = $this->colorModeConverter->cmyk2rgb($c); } return $c; } /** * @param mixed $c * @param string $color * @param string[] $PDFAXwarnings * * @return float[] */ private function restrictRgbaColorSpace($c, $color, &$PDFAXwarnings = []) { if ($this->mpdf->PDFX || ($this->mpdf->PDFA && $this->mode == 3)) { if (($this->mpdf->PDFA && !$this->mpdf->PDFAauto) || ($this->mpdf->PDFX && !$this->mpdf->PDFXauto)) { $PDFAXwarnings[] = "RGB color with transparency specified '" . $color . "' (converted to CMYK without transparency)"; } $c = $this->colorModeConverter->rgb2cmyk($c); $c = [4, $c[1], $c[2], $c[3], $c[4]]; } elseif ($this->mpdf->PDFA && $this->mode != 3) { if (!$this->mpdf->PDFAauto) { $PDFAXwarnings[] = "RGB color with transparency specified '" . $color . "' (converted to RGB without transparency)"; } $c = $this->colorModeConverter->rgb2cmyk($c); $c = [4, $c[1], $c[2], $c[3], $c[4]]; } elseif ($this->mode == 1) { $c = $this->colorModeConverter->rgb2gray($c); } elseif ($this->mode == 3) { $c = $this->colorModeConverter->rgb2cmyk($c); } return $c; } /** * @param mixed $c * @param string $color * @param string[] $PDFAXwarnings * * @return float[] */ private function restrictCmykaColorSpace($c, $color, &$PDFAXwarnings = []) { if ($this->mpdf->PDFA && $this->mode != 3) { if (($this->mpdf->PDFA && !$this->mpdf->PDFAauto) || ($this->mpdf->PDFX && !$this->mpdf->PDFXauto)) { $PDFAXwarnings[] = "CMYK color with transparency specified '" . $color . "' (converted to RGB without transparency)"; } $c = $this->colorModeConverter->cmyk2rgb($c); $c = [3, $c[1], $c[2], $c[3]]; } elseif ($this->mpdf->PDFX || ($this->mpdf->PDFA && $this->mode == 3)) { if (($this->mpdf->PDFA && !$this->mpdf->PDFAauto) || ($this->mpdf->PDFX && !$this->mpdf->PDFXauto)) { $PDFAXwarnings[] = "CMYK color with transparency specified '" . $color . "' (converted to CMYK without transparency)"; } $c = $this->colorModeConverter->cmyk2rgb($c); $c = [3, $c[1], $c[2], $c[3]]; } elseif ($this->mode == 1) { $c = $this->colorModeConverter->cmyk2gray($c); } elseif ($this->mode == 2) { $c = $this->colorModeConverter->cmyk2rgb($c); } return $c; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings