|
|
|
|
|
для: Valick
(17.05.2007 в 18:52)
| | думаю да! смотрел! Но видимо Вы не поняли моего вопроса! Создание своих функций... которые последовательно создают картинку! | |
|
|
|
|
|
|
|
для: vitalycrash
(17.05.2007 в 18:46)
| | Здесь смотрели? | |
|
|
|
|
|
|
|
для: mefestofel
(17.05.2007 в 18:38)
| | Это рабочий пример! Да и не в примере дело. Словами что мне надо: Создание Captcha по функциям, но не встроенным в библиотеку GD а создать свои. я же говорю не не до обращать внимание на пример. Рабочий пример:
<?php
session_save_path("H:/xampp/Session");
session_start();
class MyCaptcha {
var $font = 'arial.ttf';
function generateCode($characters) {
/* list all possible characters, similar looking characters and vowels have been removed */
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}
function MyCaptcha($width='80',$height='30',$characters='5') {
$code = $this->generateCode($characters);
/* font size will be 75% of the image height */
$font_size = $height * 0.35;
$image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
/* tochki */
for( $i=0; $i<($width*$height)/3; $i++ ) {
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 2, 1, $noise_color);
}
/* linii */
for( $i=0; $i<($width*$height)/150; $i++ ) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(3,$width), mt_rand(0,$height), $noise_color);
}
/* create textbox and add text */
$textbox = imagettfbbox($font_size, 2, $this->font, $code);
$x = 30;
$y = ($height - $textbox[5])/2;
imagettftext($image, $font_size, 15, $x, $y, $text_color, $this->font , $code);
/* output captcha image to browser */
imagejpeg($image);
imagedestroy($image);
$_SESSION['security_code'] = $code;
}
}
$width = isset($_GET['width']) ? $_GET['width'] : '180';
$height = isset($_GET['height']) ? $_GET['height'] : '60';
$characters = isset($_GET['characters']) ? $_GET['characters'] : '5';
header('Content-Type: image/jpeg');
$captcha = new MyCaptcha($width,$height,$characters);
session_destroy();
?>
[/code] | |
|
|
|
|
|
|
|
для: vitalycrash
(17.05.2007 в 18:31)
| | проще взять рабочий пример и разобрать
[поправлено модератором] | |
|
|
|
|
|
|
|
для: vitalycrash
(17.05.2007 в 16:08)
| | м?
ладно спасибо! | |
|
|
|
|
|
|
| Здравствуйте,
Вопрос мой больше по функциям, чем вы увидите. Продемонстрирую пример, что я хочу сделать( Вам это покажется глупо, но всё же):
Берем простую функцию создания картинки:
--------------------------
function MyCaptcha($width='80',$height='30',$characters='5') {
$code = $this->generateCode($characters);
/* font size will be 75% of the image height */
$font_size = $height * 0.35;
$image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
/* tochki */
for( $i=0; $i<($width*$height)/3; $i++ ) {
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 2, 1, $noise_color);
................................
-------------------------------
Необходимо создать функцию для создания картинки, функцию для добавления увета на картинку, симаолов. Я знаю берешь встроенные функции и всё, но мне надо свои:
-----------------------------------
class ICreate
{
function ICreate($width,$height,$color)
{
$image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');
imagejpeg($image);
imagedestroy($image);
}
function IColor($image,$color)
{
if(is_array($color)){
return imagecolorallocate($image, $color[0], $color[1], $color[2]);
}
.....
-----------------------------
Но возникает проблема: Слишком много параметров необходимо передавать. В первой функции будут все параметры что и во всех последующих. Можно ли передавать так чтобы меньше передавать т.е. Icreate-создалась картинка-передаем эту картинку на вход след. функции, добавили цвет=апгрейд картинка - следующая функция..??? Просто толкните в нужное русло.
Буду благодарен за примеры!
Спасибо | |
|
|
| |
|