1 Star 0 Fork 1

老魔/GifEncoder

forked from xiaozhuai/GifEncoder 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.cpp 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
xiaozhuai 提交于 2020-12-25 11:20 . fix header include
//
// Created by xiaozhuai on 2020/12/25.
//
#include <cstdio>
#include "GifEncoder.h"
int main() {
// Suppose that you have three frame to be encoded
const int w = 40;
const int h = 40;
uint32_t frame0[w * h];
uint32_t frame1[w * h];
uint32_t frame2[w * h];
for (int i = 0; i < w * h; ++i) {
frame0[i] = 0xFF0000FF; // red
frame1[i] = 0xFF00FF00; // green
frame2[i] = 0xFFFF0000; // blue
}
int quality = 10;
bool useGlobalColorMap = true;
int loop = 0;
int preAllocSize = useGlobalColorMap ? w * h * 3 * 3 : w * h * 3;
int delay = 20;
GifEncoder gifEncoder;
if (!gifEncoder.open("test.gif", w, h, quality, useGlobalColorMap, loop, preAllocSize)) {
fprintf(stderr, "Error open gif file\n");
return 1;
}
gifEncoder.push(GifEncoder::PIXEL_FORMAT_RGBA, (uint8_t *) frame0, w, h, delay);
gifEncoder.push(GifEncoder::PIXEL_FORMAT_RGBA, (uint8_t *) frame1, w, h, delay);
gifEncoder.push(GifEncoder::PIXEL_FORMAT_RGBA, (uint8_t *) frame2, w, h, delay);
if (!gifEncoder.close()) {
fprintf(stderr, "Error close gif file\n");
return 1;
}
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/NTLaoMo/GifEncoder.git
git@gitee.com:NTLaoMo/GifEncoder.git
NTLaoMo
GifEncoder
GifEncoder
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385