- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个程序可以用来处理各种图像文件。目前它只适用于静态图像。我想为 gif 提供支持,我一直在寻找平淡无奇的 doc你ment一个tion但找不到任何关于如何逐帧操作 gif 的引用。
理想情况下,我希望一次处理一帧 gif,使用我的其他函数处理文件中的每一帧,然后重新打包图像。
最佳答案
如果你仔细看the source code ,您可以在使用动画帧时轻松找到一个薄弱的实现。
The code does not lie: when you call
gdImageCreateFromGif(FILE *fdFile)
orgdImageCreateFromGifPtr (int size, void *data)
, it calls directly togdImageCreateFromGifCtx(gdIOCtxPtr fd)
, so you must read'n'search in that function where is the mess. The documentation has no info about it, because this library is very, very old.
在源代码中(fd06f7f on 22 Jun)第 258 行(gdImageCreateFromGifCtx(gdIOCtxPtr fd)
):
for (;;) {
int top, left;
int width, height;
if(!ReadOK(fd, &c, 1)) {
return 0;
}
if (c == ';') { /* GIF terminator */
goto terminated;
}
if(c == '!') { /* Extension */
if(!ReadOK(fd, &c, 1)) {
return 0;
}
DoExtension(fd, c, &Transparent, &ZeroDataBlock);
continue;
}
if(c != ',') { /* Not a valid start character */
continue;
}
/*1.4//++imageCount; */
if(!ReadOK(fd, buf, 9)) {
return 0;
}
useGlobalColormap = !BitSet(buf[8], LOCALCOLORMAP);
bitPixel = 1 << ((buf[8] & 0x07) + 1);
left = LM_to_uint(buf[0], buf[1]);
top = LM_to_uint(buf[2], buf[3]);
width = LM_to_uint(buf[4], buf[5]);
height = LM_to_uint(buf[6], buf[7]);
if(((left + width) > screen_width) || ((top + height) > screen_height)) {
if(VERBOSE) {
printf("Frame is not confined to screen dimension.\n");
}
return 0;
}
if(!(im = gdImageCreate(width, height))) {
return 0;
}
im->interlace = BitSet(buf[8], INTERLACE);
if(!useGlobalColormap) {
if(ReadColorMap(fd, bitPixel, localColorMap)) {
gdImageDestroy(im);
return 0;
}
ReadImage(im, fd, width, height, localColorMap, BitSet(buf[8], INTERLACE), &ZeroDataBlock);
} else {
if(!haveGlobalColormap) {
gdImageDestroy(im);
return 0;
}
ReadImage(im, fd, width, height, ColorMap, BitSet(buf[8], INTERLACE), &ZeroDataBlock);
}
if(Transparent != (-1)) {
gdImageColorTransparent(im, Transparent);
}
goto terminated;
}
goto
完成了循环,甚至没有尝试读取另一帧。
那是因为此实现旨在从 gif 中显式读取一帧。只有一个。
我在这个图书馆工作过。也有其他缺陷。 PNG 文件的透明度是 7 位,而不是 8 位(这是我使用它并在以后丢弃它的主要原因之一)。
可以打包animated gifs使用 gdImageGifAnimBegin(gdImagePtr im, FILE *outFile, int GlobalCM, int Loops)
[TL;DR]: libgd 在加载时没有多帧选项。它不是为了加载动画 gif。
关于c - 使用 libgd 在 C 中逐帧操作 gif,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52964204/
有谁知道是否可以将多个 gif 或动画 gif 加入到一个动画 gif 中(即,将这些帧连接到一个主动画 gif 中)? 我想要一些服务器端功能来执行此操作。 文件的尺寸、模式等将相同,只是内容不同。
提前道歉,但这不是一个真正的photoshop问题。相反,我试图想出一些令人信服的东西,但尽可能地利用 gif 格式的压缩和特性来为动画生成尽可能小的文件。 一些限制: 它需要至少 20 或 30 帧
如何创建播放一次并在最后一帧卡住的 GIF 图像。 我已经将循环属性设置为 1,所以第一个问题解决了。 但是动画结束后,gif并不是在最后一帧卡住,而是回到第一帧。 最佳答案 您需要将 gif 的循环
我有两个不同大小的 GIF。我希望能够将一个动画 GIF 放在特定位置的静态背景 GIF 上,同时将文本添加到结果中。我是 ImageMagick 世界的新手,请帮忙。 我试图实现以下结果,其中狗贴纸
你好 stackoverflow 世界。(这是我第一次在这里真正发布问题。令人兴奋) 不久前,我从我公司的一个团队那里继承了一个已有 2 年历史的 MVC 网站。我现在知道这个解决方案的大部分来龙去脉
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 1 年前。
我想将我的处理草图之一导出为 gif 形式,并使用 extrapixel 的 Gif 动画库 ( http://extrapixel.github.io/gif-animation/ ) 来执行此操作
我正在寻找一个可以处理动画 gif 图像并在其上写入文本的函数。 工作解决方案可能由 Gif4j lib 提供,但我正在寻找开源解决方案或建议如何自行实现它。 如何在 Java 中将文本放在 gif
这个问题在这里已经有了答案: Change File Extension Using C# (6 个答案) 关闭 8 年前。 此代码将重命名所有文件名: static private void Re
我会保持简短; 有什么方法可以区分静态 GIF 图像和动画图像吗?我正在使用 C#。 谢谢 最佳答案 Here's an article about how to determine the numb
我试图在视频上重叠动画 gif,但没有成功。 我的目标是下一个: gif 动画必须循环播放,直到视频结束。 gif 被缩放以覆盖整个视频。 gif 保留透明度。 我在这方面取得的最大成就是 gif 使
在您的网站上放置网站图标时,您显然可以使用动画 gif,只需将 gif 文件的扩展名更改为 .ico . http://www.k-director.com/blog/how-to-add-an-an
所以我试图为一个充满 gif 的文件夹添加水印,但我收到一条错误消息,说我当时只能使用一个 GIF 流,有没有办法绕过这个问题? @echo off setlocal for %%G in ("%~d
我有大约 200 张 jpg 图像。我需要堆叠它们,以便我可以将它们转换为简单的动画 gif 图像。是否有任何免费工具可以完成这项工作?我的操作系统是windows。 我不太关心输出的质量。 最佳答案
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 8 年前。 Improve th
我想使用库显示 GIF WPF Animated GIF 。但是,当设置属性 PictureSource 时,进程内存会从 208MB 增加到 1GB。为什么? XAML
几天后我有话要说。我必须引用细胞原子。我想在显示元胞自动机进化的幻灯片中显示一个小 gif,所以我的问题是:如何将使用 golly game of life 创建的模式和进化转换为动画 gif? 最佳
看这段代码: $('#loader').show(); $.post( '/action.php', function( data ) { // do anything with data $('#
作为项目的一部分,我们需要以编程方式将多个动画 GIF 以网格的形式组合成一个主动画 GIF(一个 gif 文件)。 我们不关心它是在客户端(即带有 ios/android 的智能手机)还是在服务器端
我正在制作一个小游戏。这不是 Action 游戏,而是解谜游戏,因此性能并不是那么重要。现在,我有了主游戏区,一张背景图片。在某些情况下,我想在部分背景图像上绘制其他图像。我的问题是背景图片和叠加的图
我是一名优秀的程序员,十分优秀!