Giter VIP home page Giter VIP logo

gif-h's People

Contributors

benjymous avatar charlietangora avatar jarikomppa avatar oleg-derevenetz avatar wohlstand avatar wurmd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gif-h's Issues

Blue saves as green

I wrote only white (255, 255, 255) and blue (0, 0, 255) colors, using SetPixel, and the resultant file shows up in white and green. =/

Memory Error

it is possible that treeRoot in GifGetClosestPaletteColor becomes 255.
Put an assert(treeRoot < 255) into line 110 if you want to validate that statement.
In line 113, treeRoot is used as index into GifPalette::treeSplitElt, which is a statically allocated array of size 255.
This, of course, yields to a buffer overflow.

Most of the time it goes well, it did crash yet. But it's a bug and it cost me 2 days to spot (no offense).
I guess it can be fixed easily by changing the size of the two GifPalette::treeSplit*-arrays to 256 (maybe the 255 is a typo?)

(I'm working on a PR)

Is there a simple place to flip vertically

I'm generating a gif from an OpenGL application, which has a bottom-left based coordinate system, which means my gifs all come out upside down.

Whilst it's straightforward enough to flip the buffer myself before passing it to GifWriteFrame it seems like it would be massively more efficient for the encoder to just know to read the pixels "backwards" so to speak - is there a simple place I could change this to be able to pass a "flip vertically" flag through the whole code?

Help required OpenCV Mat provided to GifWriteFrame

Any help would be appreciated. I am trying to convert a video to GIF using OpenCV. Gif output is weird.

Here is the code

    cv::Mat frame;

    GifWriter writer;

    bool success = video.read(frame);

    GifBegin(&writer, destFile.c_str(), frame.size().width, frame.size().height, 20);

    uint frameCounter = 0;

    while(success && frameCounter<=15){

        success = video.read(frame);

        GifWriteFrame(&writer,frame.data, frame.size().width, frame.size().height, 20);

        frameCounter++;

    }

    GifEnd(&writer);

    video.release();

Thanks
somegif

Any change of getting a C99 version of the library?

Hi, I would like to use gif-h on raylib to add simple .gif export functionality. That would be very useful for students to show and share their small games. Right now raylib offers automatic screenshot generation just pressing F12, some animated image would be great.

I tried it, exporting every 10 frames, and it works ok (maybe a bit slow...) but raylib is C99 and to include gif-h it requires to be compiled as C++, it's not a big deal but it should be C99 to be included in the library.

Also, would it be possible to adapt library to header-only style like STB libraries, I mean with GIF_IMPLEMENTATION define?

Undefined behaviour: Syscall param write(buf) points to uninitialised byte(s)

The following simple program creates a GIF composed of two completely white frames. But Valgrind's Memcheck complains about an uninitialized memory in GifBegin().

#include "gif.h"

static const int width = 200;
static const int height = 200;

static uint8_t image[width * height * 4];

int main(int argc, char* argv[])
{
  const char* filename = "mytest.gif";
  if (argc > 1) {
    filename = argv[1];
  }

  GifWriter writer;
  GifBegin(&writer, filename, width, height, 100);

  for (int i = 0; i < sizeof image; i += 4) {
    image[i] = image[i + 1] = image[i + 2] = 255;
    image[i + 3] = 0;  // not necessary
  }
  GifWriteFrame(&writer, image, width, height, 100);
  GifWriteFrame(&writer, image, width, height, 100);

  GifEnd(&writer);
  return 0;
}
mymedia@barberry:~/src/gif-h$ valgrind ./a.out 
==98249== Memcheck, a memory error detector
==98249== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==98249== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==98249== Command: ./a.out
==98249== 
==98249== Syscall param write(buf) points to uninitialised byte(s)
==98249==    at 0x49809B7: write (write.c:26)
==98249==    by 0x48F7E6C: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1181)
==98249==    by 0x48F9970: new_do_write (fileops.c:449)
==98249==    by 0x48F9970: _IO_new_do_write (fileops.c:426)
==98249==    by 0x48F9970: _IO_do_write@@GLIBC_2.2.5 (fileops.c:423)
==98249==    by 0x48F8F67: _IO_file_close_it@@GLIBC_2.2.5 (fileops.c:136)
==98249==    by 0x48EBE0E: fclose@@GLIBC_2.2.5 (iofclose.c:53)
==98249==    by 0x10B744: GifEnd(GifWriter*) (gif.h:827)
==98249==    by 0x10B8D1: main (mytest.c:25)
==98249==  Address 0x4abb837 is 1,175 bytes inside a block of size 4,096 alloc'd
==98249==    at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==98249==    by 0x48EBC23: _IO_file_doallocate (filedoalloc.c:101)
==98249==    by 0x48FAC6F: _IO_doallocbuf (genops.c:347)
==98249==    by 0x48F9EFF: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:745)
==98249==    by 0x48F8694: _IO_new_file_xsputn (fileops.c:1244)
==98249==    by 0x48F8694: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1197)
==98249==    by 0x48ED066: fwrite (iofwrite.c:39)
==98249==    by 0x10B342: GifBegin(GifWriter*, char const*, unsigned int, unsigned int, unsigned int, int, bool) (gif.h:754)
==98249==    by 0x10B7DD: main (mytest.c:16)
==98249== 
==98249== 
==98249== HEAP SUMMARY:
==98249==     in use at exit: 0 bytes in 0 blocks
==98249==   total heap usage: 7 allocs, 7 frees, 4,678,872 bytes allocated
==98249== 
==98249== All heap blocks were freed -- no leaks are possible
==98249== 
==98249== Use --track-origins=yes to see where uninitialised values come from
==98249== For lists of detected and suppressed errors, rerun with: -s
==98249== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Resulting GIFs only have one frame

Hello! I have been trying to use gif.h for GIF recording in my application. Long story short, it works, with one flaw. The first frame is the only one kept. Here is a sample result:
Result

The code I used is available here:

QImage &startImg = frames[0];
GifWriter writer;
GifBegin(&writer, tmpDir.absoluteFilePath("resulting.gif").toLocal8Bit().constData(), startImg.width(),
startImg.height(), d);
int i = 0;
for (QImage &a : frames) {
    QByteArray alpha8((char *)a.bits(), a.byteCount());
    GifWriteFrame(&writer, (uint8_t *)alpha8.data(), a.width(), a.height(), d);
}
GifEnd(&writer);

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.