Esempio n. 1
0
static int gifdrv_close_memmap(void)
{
    VICE_EGifCloseFile(gifdrv_memmap_fd);
    VICE_FreeMapObject(gif_colors);
    lib_free(gifdrv_memmap_ext_filename);

    return 0;
}
Esempio n. 2
0
static int gifdrv_open(screenshot_t *screenshot, const char *filename)
{
    unsigned int i;
    gfxoutputdrv_data_t *sdata;
    GifColorType ColorMap256[256];
#if GIFLIB_MAJOR >= 5
    int ec;
#endif

    if (screenshot->palette->num_entries > 256) {
        log_error(LOG_DEFAULT, "Max 256 colors supported.");
        return -1;
    }

    sdata = lib_malloc(sizeof(gfxoutputdrv_data_t));

    screenshot->gfxoutputdrv_data = sdata;

    sdata->line = 0;

    sdata->ext_filename = util_add_extension_const(filename, gif_drv.default_extension);

    sdata->fd = VICE_EGifOpenFileName(sdata->ext_filename, 0, &ec);

    if (sdata->fd == NULL) {
        lib_free(sdata->ext_filename);
        lib_free(sdata);
        return -1;
    }

    sdata->data = lib_malloc(screenshot->width);

    gif_colors = VICE_MakeMapObject(screenshot->palette->num_entries, ColorMap256);

    for (i = 0; i < screenshot->palette->num_entries; i++) {
        gif_colors->Colors[i].Blue = screenshot->palette->entries[i].blue;
        gif_colors->Colors[i].Green = screenshot->palette->entries[i].green;
        gif_colors->Colors[i].Red = screenshot->palette->entries[i].red;
    }

#if GIFLIB_MAJOR < 5
    EGifSetGifVersion("87a");
#endif

    if (EGifPutScreenDesc(sdata->fd, screenshot->width, screenshot->height, 8, 0, gif_colors) == GIF_ERROR ||
        EGifPutImageDesc(sdata->fd, 0, 0, screenshot->width, screenshot->height, 0, NULL) == GIF_ERROR) {
        VICE_EGifCloseFile(sdata->fd);
        VICE_FreeMapObject(gif_colors);
        lib_free(sdata->data);
        lib_free(sdata->ext_filename);
        lib_free(sdata);
        return -1;
    }

    return 0;
}
Esempio n. 3
0
static int gifdrv_close(screenshot_t *screenshot)
{
    gfxoutputdrv_data_t *sdata;

    sdata = screenshot->gfxoutputdrv_data;

    VICE_EGifCloseFile(sdata->fd);
    VICE_FreeMapObject(gif_colors);

    /* for some reason giflib will create a file with unexpected
       permissions. for this reason we alter them according to
       the current umask. */
    archdep_fix_permissions(sdata->ext_filename);

    lib_free(sdata->data);
    lib_free(sdata->ext_filename);
    lib_free(sdata);

    return 0;
}
Esempio n. 4
0
static int gifdrv_open_memmap(const char *filename, int x_size, int y_size, uint8_t *palette)
{
    unsigned int i;
    GifColorType ColorMap256[256];
#if GIFLIB_MAJOR >= 5
    int ec;
#endif

    gifdrv_memmap_ext_filename = util_add_extension_const(filename, gif_drv.default_extension);

    gifdrv_memmap_fd = VICE_EGifOpenFileName(gifdrv_memmap_ext_filename, 0, &ec);

    if (gifdrv_memmap_fd == NULL) {
        lib_free(gifdrv_memmap_ext_filename);
        return -1;
    }

    gif_colors = VICE_MakeMapObject(256, ColorMap256);

    for (i = 0; i < 256; i++) {
        gif_colors->Colors[i].Blue = palette[(i * 3) + 2];
        gif_colors->Colors[i].Green = palette[(i * 3) + 1];
        gif_colors->Colors[i].Red = palette[i * 3];
    }

#if GIFLIB_MAJOR < 5
    EGifSetGifVersion("87a");
#endif

    if (EGifPutScreenDesc(gifdrv_memmap_fd, x_size, y_size, 8, 0, gif_colors) == GIF_ERROR ||
        EGifPutImageDesc(gifdrv_memmap_fd, 0, 0, x_size, y_size, 0, NULL) == GIF_ERROR) {
        VICE_EGifCloseFile(gifdrv_memmap_fd);
        VICE_FreeMapObject(gif_colors);
        lib_free(gifdrv_memmap_ext_filename);
        return -1;
    }

    return 0;
}
Esempio n. 5
0
static int gifdrv_close(screenshot_t *screenshot)
{
    gfxoutputdrv_data_t *sdata;

    sdata = screenshot->gfxoutputdrv_data;

    VICE_EGifCloseFile(sdata->fd);
    VICE_FreeMapObject(gif_colors);

    /* for some reason giflib will create a file with unexpected
       permissions. for this reason we alter them according to
       the current umask.

       Carefull: oddly enough still true as of 2017-07-18, so do not remove the
       following function call without doing research/testing first (compyx)
    */
    archdep_fix_permissions(sdata->ext_filename);

    lib_free(sdata->data);
    lib_free(sdata->ext_filename);
    lib_free(sdata);

    return 0;
}