簡體   English   中英

自定義PNG翻轉功能在圖像上輸出黑色背景

[英]Custom PNG flipping function outputs black background on image

我正在使用PHP GB庫來處理圖像。 我注意到GB庫沒有提供的功能之一是能夠垂直或水平翻轉圖像。 因此,我開始為此構建自己的功能。 這就是我得到的:

function flipImage($image) {
    $width  = imagesx($image);
    $height = imagesy($image);

    $out = imagecreatetruecolor($width, $height);

    for($i = 0; $i < $width; $i++) {
        // Copy the image strip going left to right
        imagecopy($out, $image, $width - $i, 0, $i, 0, 1, $height);
    }

    //$out should now hold our flipped image
    return $out;
}

它按照我的預期工作,但是由於某種原因,返回的圖像( $out )具有黑色背景,而不是透明背景。

有什么辦法可以使返回的圖像具有與源圖像一樣的透明背景?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM