View Full Version : سوال: imagecolorexact
billgivz
دوشنبه 02 اسفند 1389, 23:56 عصر
سلام میخواستم بدونم چطور میشه خروجی تابع imagecolorexact رو که index هست به height و with تبدیل کرد
?
در ضمن این تایع کارش اینه که یک کد رنگ رو به عنوان ورودی دریافت کرده و خروجیش موقعیت کد رنگ رو عکس نشون میده البته به صورت index
http://www.php.net/manual/en/function.imagecolorexact.php
sattaryekta
سه شنبه 03 اسفند 1389, 13:38 عصر
$red = 161;
$green = 40;
$blue = 41;
/**
* create image and put pixels in of our color
*/
$pic = imagecreatetruecolor(10,10);
$white = imagecolorallocate($pic, 255, 255, 255);
$ourcolor = imagecolorallocate($pic, 161, 40, 41);
imagefill($pic, 0,0,$white);
imagefilledrectangle($pic, 5, 5, 7, 7, $ourcolor);
/**
* now find where color occurs in image
*/
$srch_rgb = ($red << 16) + ($green << 8) + $blue;
$w = imagesx ($pic);
$h = imagesy ($pic);
for ($x=0; $x<$w; $x++)
{
for ($y=0; $y<$h; $y++)
{
if (imagecolorat($pic, $x, $y) == $srch_rgb) echo "$x, $y <br/>";
}
}
منبع: http://www.phpfreaks.com/forums/php-coding-help/imagecolorexact/
billgivz
سه شنبه 03 اسفند 1389, 19:59 عصر
$red = 161;
$green = 40;
$blue = 41;
/**
* create image and put pixels in of our color
*/
$pic = imagecreatetruecolor(10,10);
$white = imagecolorallocate($pic, 255, 255, 255);
$ourcolor = imagecolorallocate($pic, 161, 40, 41);
imagefill($pic, 0,0,$white);
imagefilledrectangle($pic, 5, 5, 7, 7, $ourcolor);
/**
* now find where color occurs in image
*/
$srch_rgb = ($red << 16) + ($green << 8) + $blue;
$w = imagesx ($pic);
$h = imagesy ($pic);
for ($x=0; $x<$w; $x++)
{
for ($y=0; $y<$h; $y++)
{
if (imagecolorat($pic, $x, $y) == $srch_rgb) echo "$x, $y <br/>";
}
}
منبع: http://www.phpfreaks.com/forums/php-coding-help/imagecolorexact/
ممنون دوست عزیز
غیر از اینکه بیام تمام پیکسل ها رو بررسی کنیم راه دیگه ای نیست .
منظورم تابع خاص .
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.