Impps ကို အသုံးပြု. PHP ကိုအသုံးပြုသောအခါ agazeantialias () သည်ဘုံ function တစ်ခုဖြစ်ပြီး၎င်း၏အဓိကလုပ်ဆောင်ချက်သည်ပုံဆွဲခြင်းသို့မဟုတ်ပုံဆွဲသည့်အခါ smoother visual effect ကိုအောင်မြင်ရန်ပုံသဏ္ဌာန်သည် antialias အတွက်ဖြစ်သည်။ သို့သော်ကျွန်ုပ်တို့သည်ပုံရိပ်များကိုပွင့်လင်းမြင်သာသောနောက်ခံများဖြင့်ကျင့်သုံးသောအခါရလဒ်များမျှော်လင့်ထားသည့်အတိုင်းမဖြစ်နိုင်ပါ။ ဤဆောင်းပါးသည် အရောင်အသွေးစုံလင်သောနောက်ခံအတွက်ထိရောက်သောပုံများ နှင့်ပွင့်လင်းမြင်သာသောရုပ်ပုံများ၏ချောမွေ့မှုအပေါ်သက်ရောက်မှုကိုဆန်းစစ်လေ့လာရန်ဤဆောင်းပါးသည်စူးစမ်းလေ့လာလိမ့်မည်။
ImageanTias () သည် PHPG ၏စာကြည့်တိုက်တွင်လုပ်ဆောင်ချက်တစ်ခုဖြစ်ပြီး၎င်း၏ရှေ့ပြေးပုံစံသည်အောက်ပါအတိုင်းဖြစ်သည် -
bool imageantialias(GdImage $image, bool $enable)
Enable လုပ်တဲ့အခါမှာလိုင်းတွေ, ဘဲဥပုံတွေနဲ့အခြားဂရပ်ဖစ်တွေကိုချောမွေ့စေတယ်, ပြီးတော့ Jagging ကိုလျှော့ချလိုက်တယ်။ ၎င်းသည်ခါးဆစ်, ဂရပ်ဖစ်များနှင့် bitmaps များကိုပရိုဂရမ်များ,
ပွင့်လင်းမြင်သာသောပုံရိပ်များတွင်ရိုးရှင်းသောဥပမာတစ်ခုဖြင့်သရုပ်ဆောင်ထားကြပါစို့။
<?php
// ပွင့်လင်းနောက်ခံတစ်ခုဖန်တီးပါ PNG အရုပ်
$width = 200;
$height = 200;
$image = imagecreatetruecolor($width, $height);
// စွမ်းဆောင်နိုင်စေ alpha ပွင့်လင်းနောက်ခံကိုင်တွယ်ရန် Channel သတင်းအချက်အလက်
imagesavealpha($image, true);
$transparent = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $transparent);
// စွမ်းဆောင်နိုင်စေ抗锯齿
imageantialias($image, true);
// အနီရောင်စက်ဝိုင်းဆွဲပါ
$red = imagecolorallocate($image, 255, 0, 0);
imagefilledellipse($image, 100, 100, 100, 100, $red);
// 输出အရုပ်
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);
?>
ဒီဥပမာမှာကျွန်တော်တို့ဟာ anti-aliasing ကိုဖွင့်ပြီးပွင့်လင်းမြင်သာသောနောက်ခံပေါ်တွင်စက်ဝိုင်းတစ်ခုကိုဆွဲဆောင်နိုင်ခဲ့သည်။ သို့သော် developer တော်တော်များများက agazeanitialias () ကို enable လုပ်ထားတဲ့တောင်မှ Transparent နောက်ခံပေါ်ဆွဲထားတဲ့ဂရပ်ရဲ့အနားမှာရှိတဲ့ဂရပ်ရဲ့အနားကအနားမှာရေးဆွဲနေတုန်းပဲ။ ဘာဖြစ်လို့လဲဆိုတော့ GD စာကြည့်တိုက်ရှိ algorithms algorithms algorithms algorithms သည်မရောနှောသော pixels များပေါ်တွင်မှီခိုနေရသောကြောင့်,
anti-aliasing effect သည် aster ည့်သည်များနှင့်ပတ်သတ်သော pixels ကိုအရောင်ရောနှောခြင်းဖြင့်ချောချောမွေ့မွေ့ရရှိစေသည်။ သို့သော်ပွင့်လင်းမြင်သာသောပုံရိပ်များတွင်နောက်ခံအခြေအနေသည် 127 (လုံးဝပွင့်လင်းမြင်သာမှု), ဤနောက်ခံသည်အစိုင်အခဲနောက်ခံနှင့်တူသောအရောင်မပါ 0 င်နိုင်ပါ။ ထို့ကြောင့် anti-aliasing anti-aliasing anti-aliasing ၏ရလဒ်များမမှန်ကန်ပါက,
ဥပမာအားဖြင့်, အကယ်. သင်သည် Opaque နောက်ခံတွင်အနီရောင်စက်ဝိုင်းတစ်ခုဆွဲပါကအစွန်းတွင်အနီရောင်သည်အဖြူရောင်နောက်ခံနှင့်အတူပန်းရောင်အကူးအပြောင်းကိုဖန်တီးရန်ဖြစ်သည်။ သို့သော်ပွင့်လင်းမြင်သာသောနောက်ခံတွင်အနီရောင်သည် alpha = 127 နှင့်နောက်ခံနှင့်သာရောထွေးနိုင်သည်။
အကယ်. ImageAnias () သည် ပွင့်လင်းမြင်သာသောရုပ်ပုံများ၏အနားများကိုထိထိရောက်ရောက်ကိုင်တွယ်ခြင်းမပြုပါကအောက်ပါရွေးချယ်မှုများကိုကျင့်သုံးနိုင်သည်။
အဖြူရောင်နောက်ခံဖြင့်ယာယီအလွှာတစ်ခုဖန်တီးပါ, ပုံဆွဲခြင်းအားဆွဲဆောင်ရန် impleantialias () ကို ဖွင့်ပြီးနောက်၎င်းကိုပွင့်လင်းသောအလွှာတစ်ခုသို့ပြောင်းပါ။ ဥပမာ -
<?php
$temp = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($temp, 255, 255, 255);
imagefill($temp, 0, 0, $white);
imageantialias($temp, true);
imagefilledellipse($temp, 100, 100, 100, 100, $red);
// အဖြူနောက်ခံကိုပွင့်လင်းမြင်သာစွာပြောင်းလဲပါ
$output = imagecreatetruecolor($width, $height);
imagesavealpha($output, true);
$transparent = imagecolorallocatealpha($output, 0, 0, 0, 127);
imagefill($output, 0, 0, $transparent);
for ($x = 0; $x < $width; $x++) {
for ($y = 0; $y < $height; $y++) {
$rgb = imagecolorat($temp, $x, $y);
$colors = imagecolorsforindex($temp, $rgb);
$alpha = 127 - intval(($colors['red'] + $colors['green'] + $colors['blue']) / 3 / 2);
$newColor = imagecolorallocatealpha($output, $colors['red'], $colors['green'], $colors['blue'], max(0, min(127, $alpha)));
imagesetpixel($output, $x, $y, $newColor);
}
}
imagedestroy($temp);
header('Content-Type: image/png');
imagepng($output);
imagedestroy($output);
?>
GD စာကြည့်တိုက်၏ပုံရိပ်ထုတ်ယူမှုစွမ်းရည်သည်အကန့်အသတ်ရှိသည်။ အရည်အသွေးမြင့်မားသောအစွန်းချောမွေ့မှုနှင့်ပွ င့ ်လင်းမြင်သာသောအပြောင်းအလဲများကိုလိုအပ်ပါက Imagemagick အပေါ် အခြေခံ. ပုံရိပ်ထုတ်ယူမှုစွမ်းရည်များကိုပိုမိုကောင်းမွန်စေသည်။ ဥပမာအားဖြင့်:
<?php
$image = new Imagick();
$image->newImage(200, 200, new ImagickPixel('transparent'));
$draw = new ImagickDraw();
$draw->setFillColor('red');
$draw->circle(100, 100, 100, 50);
$image->drawImage($draw);
$image->setImageFormat("png");
header("Content-Type: image/png");
echo $image;
?>
imagemick သည်ပွင့်လင်းမြင်သာမှုအပြောင်းအလဲအတွက်,
ImageanTias () သည်အသုံးဝင်သောလုပ်ဆောင်မှုတစ်ခုဖြစ်သည်။ ပုံရိပ်များကိုပွင့်လင်းမြင်သာသောနောက်ခံနှင့်ကိုင်တွယ်ဖြေရှင်းသည့်အခါအလွန်အမင်းအကျိုးသက်ရောက်သည်။ ဘာဖြစ်လို့လဲဆိုတော့ပွင့်လင်းမြင်သာတဲ့ pixels တွေကထိရောက်တဲ့အရောင်ရောနှောမှုမှာမပါဝင်နိုင်ဘူး, ပိုမိုကောင်းမွန်သောပုံရိပ်အရည်အသွေးအတွက်ပုံရိပ်သို့မဟုတ် dual-layer drawing ကဲ့သို့သောအခြားရွေးချယ်စရာများကိုအကြံပြုပါသည်။ ၎င်းသည်ပွင့်လင်းမြင်သာသောနောက်ခံကိုထိန်းသိမ်းနေစဉ်အမှန်တကယ်ချောမွေ့သောဂရပ်ဖစ်အစွန်းကိုခွင့်ပြုသည်။