mirror of
https://github.com/Intervention/image.git
synced 2025-02-06 22:00:38 +01:00
Merge pull request #220 from jwpage/faster_alpha2gd
Rewrite Gd\Color::alpha2gd for improved performance
This commit is contained in:
commit
45e1be89c5
@ -215,15 +215,12 @@ class Color extends AbstractColor
|
||||
*/
|
||||
private function alpha2gd($input)
|
||||
{
|
||||
$range_input = range(1, 0, 1/127);
|
||||
$range_output = range(0, 127);
|
||||
$oldMin = 0;
|
||||
$oldMax = 1;
|
||||
|
||||
foreach ($range_input as $key => $value) {
|
||||
if ($value <= $input) {
|
||||
return $range_output[$key];
|
||||
}
|
||||
}
|
||||
$newMin = 127;
|
||||
$newMax = 0;
|
||||
|
||||
return 127;
|
||||
return ceil(((($input- $oldMin) * ($newMax - $newMin)) / ($oldMax - $oldMin)) + $newMin);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user