ইমেজসেটপিক্সেল() পিএইচপি-তে একটি অন্তর্নির্মিত ফাংশন যা তালিকাভুক্ত স্থানাঙ্কে একটি একক পিক্সেল সেট করতে ব্যবহৃত হয়।
সিনট্যাক্স
bool imagesetpixel(resource $image, int $x, int $y, int $color)
পরামিতি
ইমেজসেটপিক্সেল() চারটি প্যারামিটার গ্রহণ করে:$image , $x , $y এবং $color .
-
$ছবি - কাজ করার জন্য ইমেজ রিসোর্স নির্দিষ্ট করে।
-
$x − পিক্সেলের x-অর্ডিনেট নির্দিষ্ট করে।
-
$y − পিক্সেলের y-অর্ডিনেট নির্দিষ্ট করে।
-
$color − পিক্সেলের রঙ নির্দিষ্ট করে।
রিটার্ন মান −
ইমেজসেটপিক্সেল() সাফল্যের উপর সত্য এবং ব্যর্থতার উপর মিথ্যা ফেরত দেয়।
উদাহরণ 1
<?php
// Load the png image using imagecreatefromjpeg() function
$img = imagecreatefromjpeg('C:\xampp\htdocs\test\29.jpg');
// Draw the line using imagesetpixel() function
$blue = imagecolorallocate($img, 255, 255, 0);
for ($i = 0; $i < 1000; $i++) {
imagesetpixel($img, $i, 100, $blue);
}
// Show the output image to the browser
header('Content-type: image/png');
imagepng($img);
?> আউটপুট

উদাহরণ 2
<?php
$x = 700;
$y = 300;
$gd = imagecreatetruecolor($x, $y);
$corners[0] = array('x' => 100, 'y' => 10);
$corners[1] = array('x' => 0, 'y' => 170);
$corners[2] = array('x' => 190, 'y' => 170);
$blue = imagecolorallocate($gd, 255, 0, 0);
for ($i = 0; $i < 100000; $i++) {
imagesetpixel($gd, round($x),round($y), $blue);
$a = rand(0, 2);
$x = ($x + $corners[$a]['x']) / 2;
$y = ($y + $corners[$a]['y']) / 2;
}
header('Content-Type: image/png');
imagepng($gd);
?> আউটপুট
