flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > gif libraries / examples? Goto page 1, 2, 3 Next |
Author |
|
vivik 08 Apr 2018, 09:44
I need to display an animated gif in my program, how? I did jpg and png display with libjpeg and libpng, is there something like that for gif?
|
|||
08 Apr 2018, 09:44 |
|
CandyMan 08 Apr 2018, 17:51
_________________ smaller is better |
|||
08 Apr 2018, 17:51 |
|
donn 09 Apr 2018, 01:05
There are also DirectX-compatible samples provided by Microsoft:
Sample link Direct2D WIC doc If you're still using DirectX... I was able to compile and load a GIF of a shark breach from here.
|
||||||||||
09 Apr 2018, 01:05 |
|
Tomasz Grysztar 09 Apr 2018, 10:21
vivik wrote: I'd rather not use windows provided libraries for now, I want to understand the format and decoding itself. |
|||
09 Apr 2018, 10:21 |
|
vivik 09 Apr 2018, 13:01
@CandyMan
That link is giflib4, there is giflib5 around already: http://giflib.sourceforge.net/ . Not sure what the differense is yet. @Tomasz Grysztar I can't really understand that code, but it's calming to know that all decompression fits in just around 200 lines of assembly. Wish there was c code for that as well (c for reading and understanding, asm for actual using). |
|||
09 Apr 2018, 13:01 |
|
vivik 09 Apr 2018, 13:07
Things to read:
https://en.wikipedia.org/wiki/GIF https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch LZW http://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html giflib-5.1.4\lib\gif_lib.h DGifSlurp |
|||
09 Apr 2018, 13:07 |
|
pabloreda 09 Apr 2018, 13:09
in actionscript, near to C
https://github.com/theturtle32/Flash-Animated-GIF-Library/tree/master/AS3GifPlayer/src/com/worlize/gif |
|||
09 Apr 2018, 13:09 |
|
vivik 12 Apr 2018, 06:11
Hm, how to compile http://giflib.sourceforge.net/ ...
|
|||
12 Apr 2018, 06:11 |
|
vivik 17 Apr 2018, 16:44
Compiling c programs is a torture.
So I compiled giflib with msys2, and got libgif.a , To convert it to .lib (to use with visual studio), I'm using objconv from http://www.agner.org/optimize/ , with this command Code: objconv -fpe32 -nu libgif.a libgif.lib So I'll use libgif.lib and gif_lib.h , need to check if they work. |
|||
17 Apr 2018, 16:44 |
|
vivik 17 Apr 2018, 17:43
Tried this:
Code: FILE *file; file = _wfopen(L"256x256_rgb_a_gif_1f.gif", L"rb"); int error; GifFileType *gifFile = DGifOpenFileHandle((int)file, &error); DGifSlurp(gifFile); Got this: Code: libgif.lib(openbsd-reallocarray.o) : error LNK2001: unresolved external symbol ___errno So, after all, I compiled it wrong. I need to compile it with visual studio for it to work. |
|||
17 Apr 2018, 17:43 |
|
vivik 17 Apr 2018, 17:53
Welp, at least now I have config.h and such. Maybe it will help figure out what is going on in the code.
Need to write CMakeLists.txt (cmake config) for giflib. Need to clean up CMakeLists.txt for libjpeg and libpng, and then wirte CMakeLists.txt for giflib. Cmake is quite confusing, but it still seems less confusing than makefiles and visual studio projects. |
|||
17 Apr 2018, 17:53 |
|
revolution 18 Apr 2018, 00:46
vivik wrote: Compiling c programs is a torture. |
|||
18 Apr 2018, 00:46 |
|
vivik 18 Apr 2018, 16:48
It's simple, if you and the guy who wrote the program have the same compiler, and the same version of that compiler. Which is rarely the case.
If program supports too many different compilers and oses, it becomes complicated for different reasons: many #ifdef. I don't know if it's possible to do something about it, other than documenting everything well and the usual git gud. One day there will be a tool to remove unrelated code automatically, and it probably already exists. |
|||
18 Apr 2018, 16:48 |
|
vivik 18 Apr 2018, 16:53
giflib 5 includes <unistd.h>, so I guess it's POSIX only. Can't compile with visual studio then.
Also, problems with "bool" and <stdbool.h>, https://stackoverflow.com/questions/5680340/c-doesnt-have-a-bool-also-vs2010-question Switching to "giflib 4 for windows" from the second post. |
|||
18 Apr 2018, 16:53 |
|
vivik 18 Apr 2018, 17:48
Okay, it compiled. Used dgif_lib.c gifalloc.c gif_err.c , with all the headers. (don't need egif_lib.c , I'm not encoding anything yet.) Created a new VS project for these. Added #define GIFLIB_STATIC in gif_lib.h .
There is fdopen inside, I'm not sure what this supposed to mean. Some streams, how is that different from the usual fopen? Need to replace that with something... |
|||
18 Apr 2018, 17:48 |
|
vivik 19 Apr 2018, 18:30
Compiled. It works now. This is a quite simple library, much much simpler than libpng for example. It doesn't really need config.h , they create it to silence some warning somewhere.
Since it's version 4, I can't get delay information for animation. Maybe I'll just copypaste a bit of code from version 5... Last edited by vivik on 19 Apr 2018, 18:33; edited 1 time in total |
|||
19 Apr 2018, 18:30 |
|
vivik 19 Apr 2018, 18:32
Good info about gif delay and timing: https://humpy77.deviantart.com/journal/Frame-Delay-Times-for-Animated-GIFs-214150546
http://www.humpy.demon.co.uk/da/gif_timing/ For my browser, delay 2 is actually faster than delay 1 and delay 0. Weird. |
|||
19 Apr 2018, 18:32 |
|
vivik 19 Apr 2018, 18:45
By the way, back in 2012 I downloaded a few pieces of pixelart from pixiv. I converted all gif images to png. Most of them became smaller, but a few became bigger instead. Here are those "anomalies".
I don't know what is the cause exactly, I guess gif header is smaller than png header. And not all images benefit from png "vertical compression", the simple horizontal compression from gif is enough for them.
|
||||||||||||||||||||||||||||
19 Apr 2018, 18:45 |
|
DimonSoft 20 Apr 2018, 03:37
vivik wrote: It doesn't really need config.h , they create it to silence some warning somewhere. <OffTop>I like the way C/C++ folks do stuff that in any other language community is considered evil. A few years later someone comes across a piece of software written with such tricks and starts a new “Why software sucks” thread.</OffTop> |
|||
20 Apr 2018, 03:37 |
|
Goto page 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.