回答編集履歴
1
追記
answer
CHANGED
@@ -3,18 +3,57 @@
|
|
3
3
|
|
4
4
|
[https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif](https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif)
|
5
5
|
|
6
|
+
追記
|
7
|
+
NETSCAPE2.0拡張ですね。それなら、そう書かないとわかりませんよ。もっと質問の仕方も勉強しましょう。
|
8
|
+
また、もっと感謝の気持ちを表さないと、回答をもらえなくなりますよ。
|
9
|
+
以下のコードで、繰り返し回数が取れました。地球のGIF Animation では0xffff = 無限繰り返しになっています。0xffff なのをとれていないと誤解していたか、元のコードでは >=3 で繰り返しのブロックと判定していましたので、delay のブロックも繰り返しのブロックと認識されて、上書きされてしまったのではないでしょうか。
|
10
|
+
|
6
11
|
```lang-C
|
7
12
|
#include <stdio.h>
|
8
13
|
#include <stdlib.h>
|
14
|
+
#include <string.h>
|
9
15
|
#include <gif_lib.h>
|
10
16
|
|
11
17
|
int main(int argc, char *argv[])
|
12
18
|
{
|
13
19
|
int error;
|
20
|
+
SavedImage *image;
|
21
|
+
int loop_count = -1;
|
22
|
+
int i, k;
|
14
23
|
|
15
24
|
GifFileType *gifFile = DGifOpenFileName("C:\\temp\\earth.gif", &error);
|
16
25
|
DGifSlurp(gifFile);
|
17
26
|
printf("count %d\n", gifFile->ImageCount);
|
18
27
|
|
28
|
+
for (i = 0; i < gifFile->ImageCount; ++i)
|
29
|
+
{
|
30
|
+
image = &(gifFile->SavedImages[i]);
|
31
|
+
for (k = 0; k < image->ExtensionBlockCount; ++k)
|
32
|
+
{
|
33
|
+
ExtensionBlock *block = &image->ExtensionBlocks[k];
|
34
|
+
switch (block->Function)
|
35
|
+
{
|
36
|
+
case APPLICATION_EXT_FUNC_CODE:
|
37
|
+
if (block->ByteCount == 11)
|
38
|
+
{
|
39
|
+
if (memcmp(block->Bytes, "NETSCAPE2.0", 11) == 0)
|
40
|
+
{
|
41
|
+
if (i + 1 < image->ExtensionBlockCount)
|
42
|
+
{
|
43
|
+
++block;
|
44
|
+
if ((block->ByteCount == 3) && ((block->Bytes[0] & 7) == 1))
|
45
|
+
{
|
46
|
+
loop_count =
|
47
|
+
((block->Bytes[1] & 0xFF) |
|
48
|
+
((block->Bytes[2] & 0xFF) << 8));
|
49
|
+
printf("loop count found %d\n", loop_count);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
break;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
19
58
|
}
|
20
59
|
```
|