שלום לכולם.התקנתי PHP גרסת ZIP (זו שמכילה מלא EXTENSIONS), והתקנתי GD2, לעיבוד תמונה.
אני מנסה לכתוב דף קטן, שידע להגיד לי אם נקודה שחורה בתמונה (היחידה התמונה), היא באותו קו של נקודה אדומה התמונה על ציר ה - Y.
זה מה שניסיתי :
<?php// create an image $im = ImageCreateFromJPEG("1.jpg"); // white background and blue text $bg = imagecolorallocate($im, 255, 255, 0); $textcolor = imagecolorallocate($im, 0, 0, 255); // write the string at the top left //imagestring($im, 5, 0, 0, "Hello world!11", $textcolor); // output the image header("Content-type: image/jpg"); $width = imagesx($im); $height = imagesy($im); $blackX = 0; $blackY = 0; $redX = 0; $redY = 0; for ($cy=0;$cy<$height;$cy++) { for ($cx=0;$cx<$width;$cx++) { $rgb = ImageColorAt($im, $cx, $cy); if ($rgb == imagecolorexact($im, 0, 0, 0)) { $blackX = $cx; $blackY = $cy; } } } for ($cy=0;$cy<$height;$cy++) { for ($cx=0;$cx<$width;$cx++) { $rgb = imagecolorat($im, $cx, $cy); if ($rgb == imagecolorexact($im, 255, 0, 0)) { $redX = $cx; $redY = $cy; } } } if ($blackY == $redY) imagestring($im, 2, 0, 0, "Points Match!", $textcolor); else imagestring($im, 2, 0, 0, "Points Do Not Match!", $textcolor); imagejpeg($im); ?>
|
הנה התמונה שאיתה אני עובד :
http://n.rotter.net/User_files/nor/40442a052ba117e0.jpg
משום מה, הערכים blackY ו - blackX הם תמיד 0.
יש למישהו מושג למה ?
תודה