芝麻web文件管理V1.00
编辑当前文件:/home/c7lekhnath/silverray.com.au/vendor/intervention/image/src/Drivers/Gd/ColorProcessor.php
convertTo($this->colorspace); // gd only supports rgb so the channels can be accessed directly $r = $color->channel(Red::class)->value(); $g = $color->channel(Green::class)->value(); $b = $color->channel(Blue::class)->value(); $a = $color->channel(Alpha::class)->value(); // convert alpha value to gd alpha // ([opaque]255-0[transparent]) to ([opaque]0-127[transparent]) $a = (int) $this->convertRange($a, 0, 255, 127, 0); return ($a << 24) + ($r << 16) + ($g << 8) + $b; } public function nativeToColor(mixed $value): ColorInterface { if (!is_int($value)) { throw new ColorException('GD driver can only decode colors in integer format.'); } $a = ($value >> 24) & 0xFF; $r = ($value >> 16) & 0xFF; $g = ($value >> 8) & 0xFF; $b = $value & 0xFF; // convert gd apha integer to intervention alpha integer // ([opaque]0-127[transparent]) to ([opaque]255-0[transparent]) $a = (int) static::convertRange($a, 127, 0, 0, 255); return new Color($r, $g, $b, $a); } /** * Convert input in range (min) to (max) to the corresponding value * in target range (targetMin) to (targetMax). * * @param float|int $input * @param float|int $min * @param float|int $max * @param float|int $targetMin * @param float|int $targetMax * @return float|int */ protected function convertRange( float|int $input, float|int $min, float|int $max, float|int $targetMin, float|int $targetMax ): float|int { return ceil(((($input - $min) * ($targetMax - $targetMin)) / ($max - $min)) + $targetMin); } }