static function colorize($image, $rgb_code) { imageTrueColorToPalette($image, true, 256); $num_colors = imageColorsTotal($image); for ($x = 0; $x < $num_colors; $x++) { list($r, $g, $b) = array_values(imageColorsForIndex($image, $x)); $gray_scale = ($r + $g + $b) / 3 / 0xff; imageColorSet($image, $x, $gray_scale * $rgb_code[0], $gray_scale * $rgb_code[1], $gray_scale * $rgb_code[2]); } }
function Colorize($IMG, $RGB) { imageTrueColorToPalette($IMG, true, 256); $numColors = imageColorsTotal($IMG); for ($x = 0; $x < $numColors; $x++) { list($r, $g, $b) = array_values(imageColorsForIndex($IMG, $x)); $grayscale = ($r + $g + $b) / 3 / 0xff; imageColorSet($IMG, $x, $grayscale * $RGB[0], $grayscale * $RGB[1], $grayscale * $RGB[2]); } }
/** * Write the image after being processed * * @param Asido_TMP &$tmp * @return boolean * @access protected */ function __write(&$tmp) { // try to guess format from extension // if (!$tmp->save) { $p = pathinfo($tmp->target_filename); ($tmp->save = $this->__mime_metaphone[metaphone($p['extension'])]) || ($tmp->save = $this->__mime_soundex[soundex($p['extension'])]); } $result = false; $imgContent = null; switch ($tmp->save) { case 'image/gif': imageTrueColorToPalette($tmp->target, true, 256); ob_start(); $result = @imageGIF($tmp->target); $imgContent = ob_get_clean(); break; case 'image/jpeg': ob_start(); $result = @imageJPEG($tmp->target, null, ASIDO_GD_JPEG_QUALITY); $imgContent = ob_get_clean(); break; case 'image/wbmp': ob_start(); $result = @imageWBMP($tmp->target); $imgContent = ob_get_clean(); break; default: case 'image/png': imageSaveAlpha($tmp->target, true); imageAlphaBlending($tmp->target, false); ob_start(); $result = @imagePNG($tmp->target, null, ASIDO_GD_PNG_QUALITY); $imgContent = ob_get_clean(); break; } if ($result) { jimport('joomla.filesystem.file'); JFile::write($tmp->target_filename, $imgContent); } @$this->__destroy_source($tmp); @$this->__destroy_target($tmp); return $result; }
public function image_colorize($rgb) { imageTrueColorToPalette($this->imageResized, true, 256); $numColors = imageColorsTotal($this->imageResized); for ($x = 0; $x < $numColors; $x++) { list($r, $g, $b) = array_values(imageColorsForIndex($this->imageResized, $x)); // calculate grayscale in percent $grayscale = ($r + $g + $b) / 3 / 0xff; imageColorSet($this->imageResized, $x, $grayscale * $rgb[0], $grayscale * $rgb[1], $grayscale * $rgb[2]); } return true; }
/** * Write the image after being processed * * @param Asido_TMP &$tmp * @return boolean * @access protected */ function __write(&$tmp) { // try to guess format from extension // if (!$tmp->save) { $p = pathinfo($tmp->target_filename); ($tmp->save = $this->__mime_metaphone[metaphone($p['extension'])]) || ($tmp->save = $this->__mime_soundex[soundex($p['extension'])]); } $result = false; switch ($tmp->save) { case 'image/gif': imageTrueColorToPalette($tmp->target, true, 256); $result = @imageGIF($tmp->target, $tmp->target_filename); break; case 'image/jpeg': $result = @imageJPEG($tmp->target, $tmp->target_filename, ASIDO_GD_JPEG_QUALITY); break; case 'image/wbmp': $result = @imageWBMP($tmp->target, $tmp->target_filename); break; default: case 'image/png': imageSaveAlpha($tmp->target, true); imageAlphaBlending($tmp->target, false); $result = @imagePNG($tmp->target, $tmp->target_filename); break; } @$this->__destroy_source($tmp); @$this->__destroy_target($tmp); return $result; }
function image_colorize4(&$img, $rgb) { imageTrueColorToPalette($img, true, 256); $numColors = imageColorsTotal($img); for ($x = 0; $x < $numColors; $x++) { list($r, $g, $b) = array_values(imageColorsForIndex($img, $x)); $grayscale = ($r + $g + $b) / 3 / 0xff; imageColorSet($img, $x, $grayscale * $rgb[0], $grayscale * $rgb[1], $grayscale * $rgb[2]); } }
/** * Функция генерирует и выводит хидер PNG и изображение с кодом подтверждения (код берется из массива полей) * Возвращает результат выполнения imagePNG * @return bool */ function confirmImage() { $width = ajaxform::$captcha[width]; $height = ajaxform::$captcha[height]; $multi = 4; $xwidth = $width * $multi; $xheight = $height * $multi; $code = $this->fields[confirm][value]; $im = imageCreateTrueColor($xwidth, $xheight); $w = imageColorAllocate($im, 255, 255, 255); $b = imageColorAllocate($im, 000, 000, 000); $g = imageColorAllocate($im, 100, 100, 100); imageFill($im, 1, 1, $w); $w = imageColorTransparent($im, $w); $r = mt_rand(0, $xheight); for ($x = 0; $x < $xwidth + $xheight; $x += 4 * $multi) { for ($i = 0; $i < $multi; $i++) imageLine($im, $x + $i, 0, $x + $i - $xheight, $xheight + $r, $g); } $arr = preg_split('//', $code, -1, PREG_SPLIT_NO_EMPTY); for ($i = 0; $i < count($arr); $i++) { $x = ($xwidth * 0.04) + (floor(($xwidth * 0.97) * 0.167)) * $i; // разрядка $y = ($xheight * 0.8); $s = ($xheight * 0.5) * (96 / 72); // 96 — res $a = mt_rand(-20, 20); imageTTFText($im, $s, $a, $x, $y, $b, $_SERVER[DOCUMENT_ROOT] . "/lib/core/classes/form_ajax/consolas.ttf", $arr[$i]); // } $temp = imageCreateTrueColor($xwidth, $xheight); $w = imageColorAllocate($temp, 255, 255, 255); imageFill($temp, 1, 1, $w); $w = imageColorTransparent($temp, $w); $phase = rand(-M_PI, M_PI); $frq = 2 * M_PI / $xheight; $amp = $xwidth * 0.02; for ($y = 0; $y < $xheight; $y++) { $dstx = $amp + sin($y * $frq + $phase) * $amp; imagecopy($temp, $im, $dstx, $y, 0, $y, $xwidth, 1); //imagesetpixel($im, $dstx, $y, $b); } $res = imageCreateTrueColor($width, $height); $w = imageColorAllocate($res, 255, 255, 255); imageFill($res, 1, 1, $w); $w = imageColorTransparent($res, $w); imageCopyResampled($res, $temp, 0, 0, 0, 0, $width, $height, $xwidth, $xheight); imageTrueColorToPalette($res, true, 256); header("CONTENT-TYPE: IMAGE/PNG"); return imagePNG($res); }
/** * Write the image after being processed * * @param Asido_TMP &$tmp * @return boolean * @access protected */ function __write(&$tmp) { // try to guess format from extension // if (!$tmp->save) { $p = pathinfo($tmp->target_filename); ($tmp->save = $this->__mime_metaphone[metaphone($p['extension'])]) || ($tmp->save = $this->__mime_soundex[soundex($p['extension'])]); } $result = false; switch ($tmp->save) { case 'image/gif': imageTrueColorToPalette($tmp->target, true, 256); ob_start(); imageGIF($tmp->target); $contents = ob_get_contents(); ob_end_clean(); break; case 'image/jpeg': ob_start(); imageJPEG($tmp->target, null, ASIDO_GD_JPEG_QUALITY); $contents = ob_get_contents(); ob_end_clean(); break; case 'image/wbmp': ob_start(); imageWBMP($tmp->target); $contents = ob_get_contents(); ob_end_clean(); break; default: case 'image/png': imageSaveAlpha($tmp->target, true); imageAlphaBlending($tmp->target, false); ob_start(); imagePNG($tmp->target); $contents = ob_get_contents(); ob_end_clean(); break; } // This needs to go through Joomla as suexec might be present jimport('joomla.filesystem'); $result = JFile::write($tmp->target_filename, $contents); $this->__destroy_source($tmp); $this->__destroy_target($tmp); return $result; }
$arcount++; } $deletedays = count($data_array); $first_entry = 10; // disable tsgk map function if (count($data_array) > 1) { drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'kills', 0, 1, 0, 1, array($red, $red, $font_color, $dark_color, $light_gray)); drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'headshots', 0, 0, 0, 1, array($dark_color, $red, $font_color, $dark_color, $light_gray)); drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'skill', 0, 0, 0, 1, array($orange, $red, $font_color, $dark_color, $light_gray)); drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 2, 'deaths', 0, 0, 0, 1, array($gray, $red, $font_color, $dark_color, $light_gray)); } $str = $deletedays . ' days Trend'; $str_width = imagefontwidth(1) * strlen($str) + 2; imagestring($image, 1, $width - $indent_x[1] - $str_width, $indent_y[0] - 11, $str, $font_color); } imageTrueColorToPalette($image, 0, 65535); // $bar_type=2; // achtung, hier ist noch ein pfad hardcoded!!! header('Content-Type: image/png'); if ($bar_type != 2) { @imagepng($image, IMAGE_PATH . '/progress/server_' . $width . '_' . $height . '_' . $bar_type . '_' . $game . '_' . $server_id . '_' . $bg_id . '_' . $server_load_type . '.png'); $mod_date = date('D, d M Y H:i:s \\G\\M\\T', time()); header('Last-Modified:' . $mod_date); imagepng($image); imagedestroy($image); //Opera doesn't like the redirect /*$mod_date = date('D, d M Y H:i:s \G\M\T', time()); header('Last-Modified:'.$mod_date); header("Location: ".IMAGE_PATH."/progress/server_".$width."_".$height."_".$bar_type."_".$game."_".$server_id."_".$bg_id."_".$server_load_type.".png");*/ } else { imagepng($image);