Skip to content

Commit

Permalink
add gif image reading support
Browse files Browse the repository at this point in the history
this adds an included dependency for gifdec, which is in public domain.

the build process is changed to just a powershell script for now, but
that'll probably change once i rewrite this project using vulkan
  • Loading branch information
Walavouchey committed Nov 12, 2021
1 parent 6ebf336 commit 6a254da
Show file tree
Hide file tree
Showing 7 changed files with 716 additions and 6 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ options:

## Compilation

On Windows, you can compile with clang (you can get it by installing [LLVM](https://releases.llvm.org/download.html)) like this:

```
clang .\osb2mp4.cpp -std=c++17 -I .\lib\ -I C:\path\to\opencv\build\include\ -L C:\path\to\opencv\build\x64\vc15\lib\ -l opencv_world451 -O3 -fopenmp -o .\osb2mp4.exe
```
On Windows, you can compile with clang (you can get it by installing [LLVM](https://releases.llvm.org/download.html)) by running the included `make.ps1` script. Be sure to fill in the templated variables at the top of the file.

When running, make sure to have `opencv_videoio_ffmpeg451_64.dll` and `opencv_world451.dll` in the same folder as `osb2mp4.exe`.
56 changes: 56 additions & 0 deletions dep/gifdec/lib/gifdec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef GIFDEC_H
#define GIFDEC_H

#include <stdint.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct gd_Palette {
int size;
uint8_t colors[0x100 * 3];
} gd_Palette;

typedef struct gd_GCE {
uint16_t delay;
uint8_t tindex;
uint8_t disposal;
int input;
int transparency;
} gd_GCE;

typedef struct gd_GIF {
int fd;
off_t anim_start;
uint16_t width, height;
uint16_t depth;
uint16_t loop_count;
gd_GCE gce;
gd_Palette *palette;
gd_Palette lct, gct;
void (*plain_text)(
struct gd_GIF *gif, uint16_t tx, uint16_t ty,
uint16_t tw, uint16_t th, uint8_t cw, uint8_t ch,
uint8_t fg, uint8_t bg
);
void (*comment)(struct gd_GIF *gif);
void (*application)(struct gd_GIF *gif, char id[8], char auth[3]);
uint16_t fx, fy, fw, fh;
uint8_t bgindex;
uint8_t *canvas, *frame;
} gd_GIF;

gd_GIF *gd_open_gif(const char *fname);
int gd_get_frame(gd_GIF *gif);
void gd_render_frame(gd_GIF *gif, uint8_t *buffer);
int gd_is_bgcolor(gd_GIF *gif, uint8_t color[3]);
void gd_rewind(gd_GIF *gif);
void gd_close_gif(gd_GIF *gif);

#ifdef __cplusplus
}
#endif

#endif /* GIFDEC_H */
Loading

0 comments on commit 6a254da

Please sign in to comment.