【问题标题】:Transparency with GifCreator php class not workingGifCreator php 类的透明度不起作用
【发布时间】:2014-07-18 08:51:29
【问题描述】:

我尝试使用 Gifcreator php 类从 10 个 PNG 图像创建动画 GIF 图像。 动画图像已创建,但原始图像的透明度丢失。我有一个黑色的背景。 文档说透明度由第一个加载的图像确定。这 10 张图像具有透明背景。我在 Paint 中加载了 htem,它说它是基于白色的。

有没有人解决这个问题?

谢谢,

课程在这里:https://github.com/Sybio/GifCreator

我的脚本在这里:http://www.egloff.eu/rsmaptest/slideshow.php

这里的第一张图片:http://www.egloff.eu/rsmaptest/images/image0.png

代码:

<?php
// Include the class
require_once('./testcreator/GifCreator.php');

// Instanciate the class (uses default options with the addition of width/height  specified)
$gif = new GifCreator(0, 2, array(0, 0, 0),550,550);

// Add each frame to the animation
$gif->addFrame(file_get_contents('images/image9.png'), 100, true);
$gif->addFrame(file_get_contents('images/image8.png'), 100, true);
$gif->addFrame(file_get_contents('images/image7.png'), 100, true);
$gif->addFrame(file_get_contents('images/image6.png'), 100, true);
$gif->addFrame(file_get_contents('images/image5.png'), 100, true);
$gif->addFrame(file_get_contents('images/image4.png'), 100, true);
$gif->addFrame(file_get_contents('images/image3.png'), 100, true);
$gif->addFrame(file_get_contents('images/image2.png'), 100, true);
$gif->addFrame(file_get_contents('images/image1.png'), 100, true);
$gif->addFrame(file_get_contents('images/image0.png'), 500, true);


// Output the animated gif
header('Content-type: image/gif');
echo $gif->getAnimation();
?>

【问题讨论】:

  • 我的问题出在哪里?贴出来的cmets都去哪儿了?
  • 问题的问题在“保留”框中描述。现在您添加了必要的信息,我重新投票。答案很可能是作者在意识到答案不正确后删除的。

标签: php image class transparency


【解决方案1】:

我找到了我自己问题的答案,它可能会帮助其他人使用相同的库或基于 László Zsidi 的相同原创作品的其他库。

在课堂上,您必须将以下出现在一处或另一处的部分替换为 2 行:

$Locals_ext = "!\xF9\x04" . chr ( ( $this->DIS << 2 ) + 0 ) .

这个

$Locals_ext = "!\xF9\x04" . chr ((( $this->DIS << 2 )) | 1 + 0 ) .

这解决了我的问题,透明度现在可以正常工作了。我尝试了 3 个不同的课程,发现都是基于相同的工作。

我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2012-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 2012-11-04
    • 2023-04-03
    相关资源
    最近更新 更多