1 Star 0 Fork 64

luckyleejin/third_party_giflib

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gifsponge.c 2.73 KB
一键复制 编辑 原始数据 按行查看 历史
mamingshuai 提交于 2021-03-11 18:38 . update openharmony 1.0.1
/****************************************************************************
gifsponge.c - skeleton file for generic GIF `sponge' program
Slurp a GIF into core, operate on it, spew it out again. Most of the
junk above `int main' isn't needed for the skeleton, but is likely to
be for what you'll do with it.
If you compile this, it will turn into an expensive GIF copying routine;
stdin to stdout with no changes and minimal validation. Well, it's a
decent test of DGifSlurp() and EGifSpew(), anyway.
Note: due to the vicissitudes of Lempel-Ziv compression, the output of this
copier may not be bitwise identical to its input. This can happen if you
copy an image from a much more (or much *less*) memory-limited system; your
compression may use more (or fewer) bits. The uncompressed rasters should,
however, be identical (you can check this with gifbuild -d).
SPDX-License-Identifier: MIT
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "gif_lib.h"
#include "getarg.h"
#define PROGRAM_NAME "gifsponge"
int main(int argc, char **argv)
{
int i, ErrorCode;
GifFileType *GifFileIn, *GifFileOut = (GifFileType *)NULL;
if ((GifFileIn = DGifOpenFileHandle(0, &ErrorCode)) == NULL) {
PrintGifError(ErrorCode);
exit(EXIT_FAILURE);
}
if (DGifSlurp(GifFileIn) == GIF_ERROR) {
PrintGifError(GifFileIn->Error);
exit(EXIT_FAILURE);
}
if ((GifFileOut = EGifOpenFileHandle(1, &ErrorCode)) == NULL) {
PrintGifError(ErrorCode);
exit(EXIT_FAILURE);
}
/*
* Your operations on in-core structures go here.
* This code just copies the header and each image from the incoming file.
*/
GifFileOut->SWidth = GifFileIn->SWidth;
GifFileOut->SHeight = GifFileIn->SHeight;
GifFileOut->SColorResolution = GifFileIn->SColorResolution;
GifFileOut->SBackGroundColor = GifFileIn->SBackGroundColor;
if (GifFileIn->SColorMap) {
GifFileOut->SColorMap = GifMakeMapObject(
GifFileIn->SColorMap->ColorCount,
GifFileIn->SColorMap->Colors);
} else {
GifFileOut->SColorMap = NULL;
}
for (i = 0; i < GifFileIn->ImageCount; i++)
(void) GifMakeSavedImage(GifFileOut, &GifFileIn->SavedImages[i]);
/*
* Note: don't do DGifCloseFile early, as this will
* deallocate all the memory containing the GIF data!
*
* Further note: EGifSpew() doesn't try to validity-check any of this
* data; it's *your* responsibility to keep your changes consistent.
* Caveat hacker!
*/
if (EGifSpew(GifFileOut) == GIF_ERROR)
PrintGifError(GifFileOut->Error);
if (DGifCloseFile(GifFileIn, &ErrorCode) == GIF_ERROR)
PrintGifError(ErrorCode);
return 0;
}
/* end */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/luckyleejin/third_party_giflib.git
[email protected]:luckyleejin/third_party_giflib.git
luckyleejin
third_party_giflib
third_party_giflib
master

搜索帮助