forked from unity3d-jp/FrameCapturer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGifTest.cpp
44 lines (36 loc) · 1.23 KB
/
GifTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "TestCommon.h"
template<class T>
void GifTestImpl(const char *filename)
{
const int Width = 320;
const int Height = 240;
const int frame_count = 30;
fcGifConfig conf;
conf.width = Width;
conf.height = Height;
fcIGifContext *ctx = fcGifCreateContext(&conf);
fcTime t = 0;
TBuffer<T> video_frame(Width * Height);
for (int i = 0; i < frame_count; ++i) {
CreateVideoData(&video_frame[0], Width, Height, i);
fcGifAddFramePixels(ctx, &video_frame[0], GetPixelFormat<T>::value, false, t);
t += 1.0 / 30.0;
}
fcStream *fstream = fcCreateFileStream(filename);
fcGifWrite(ctx, fstream);
fcDestroyStream(fstream);
fcGifDestroyContext(ctx);
}
void GifTest()
{
printf("GifTest begin\n");
fcTaskGroup group;
group.run([]() { GifTestImpl<RGBu8>("RGBu8.gif"); });
group.run([]() { GifTestImpl<RGBf16>("RGBf16.gif"); });
group.run([]() { GifTestImpl<RGBf32>("RGBf32.gif"); });
group.run([]() { GifTestImpl<RGBAu8>("RGBAu8.gif"); });
group.run([]() { GifTestImpl<RGBAf16>("RGBAf16.gif"); });
group.run([]() { GifTestImpl<RGBAf32>("RGBAf32.gif"); });
group.wait();
printf("GifTest end\n");
}