This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 3062e03a9503f1b624fc80fc91b76b129646cf01 (commit) via de4f3fac6d2249efeb6023d2f9ce8c6e0cf96b61 (commit) via 33cedf107e230a76204bee5ea1ee0aab853023fc (commit) via 86c1e0faccd6228843fa35d6f7f2bf54ab57fa11 (commit) via 475c56e9cccddae51438fec2b1ddfb546fa8b20a (commit) from 7fe49055375ddf8ad4216a8abf25146ee49a4859 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/3062e03a9503f1b624fc80fc91b76b129646c...
commit 3062e03a9503f1b624fc80fc91b76b129646cf01 Author: Cyril Hrubis metan@ucw.cz Date: Wed Jul 10 00:26:41 2013 +0200
spiv: Small cleanup.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 287cc12..bd3194c 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -33,7 +33,6 @@ #include <pthread.h>
#include <GP.h> -#include <input/GP_InputDriverLinux.h>
#include "image_cache.h" #include "image_list.h" @@ -270,7 +269,8 @@ static GP_Context *load_image(struct loader_params *params, int elevate) /* * Fill context with chessboard-like pattern. */ -static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0, unsigned int w, unsigned int h) +static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0, + unsigned int w, unsigned int h) { unsigned int x, y;
@@ -633,7 +633,6 @@ static void init_backend(const char *backend_opts) } }
- static void init_caches(struct loader_params *params) { size_t size = image_cache_get_ram_size(); @@ -796,11 +795,9 @@ int main(int argc, char *argv[]) }
for (;;) { - GP_BackendWait(backend); - GP_Event ev;
- while (GP_BackendGetEvent(backend, &ev)) { + while (GP_BackendWaitEvent(backend, &ev)) {
shift_flag = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) || GP_EventGetKey(&ev, GP_KEY_RIGHT_SHIFT); @@ -1025,7 +1022,5 @@ int main(int argc, char *argv[]) } }
- GP_BackendExit(backend); - return 0; }
http://repo.or.cz/w/gfxprim.git/commit/de4f3fac6d2249efeb6023d2f9ce8c6e0cf96...
commit de4f3fac6d2249efeb6023d2f9ce8c6e0cf96b61 Author: Cyril Hrubis metan@ucw.cz Date: Wed Jul 10 00:25:36 2013 +0200
core: Fix typon in GP_Threads.h
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/core/GP_Threads.h b/include/core/GP_Threads.h index 69da584..204ebe7 100644 --- a/include/core/GP_Threads.h +++ b/include/core/GP_Threads.h @@ -76,7 +76,7 @@ struct GP_ProgressCallbackMPPriv { * * The intended usage is: * - * GP_PROGRESS_CALLBACK(callback_mp, orig_callback); + * GP_PROGRESS_CALLBACK_MP(callback_mp, orig_callback); * * ... *
http://repo.or.cz/w/gfxprim.git/commit/33cedf107e230a76204bee5ea1ee0aab85302...
commit 33cedf107e230a76204bee5ea1ee0aab853023fc Author: Cyril Hrubis metan@ucw.cz Date: Wed Jul 10 00:21:41 2013 +0200
loaders: Add image containers + ZIP container.
Image container is an abstraction for image formats capable of storing several images. The container could be opened and image loaded one by one.
ZIP container is first container implementation, it can load images from a ZIP file, so far it can only handle JPEGs and deflate compressed ZIPs. This is also base code for implementing CBZ support for spiv.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/configure b/configure index 971a960..7a3b93d 100755 --- a/configure +++ b/configure @@ -321,7 +321,10 @@ if __name__ == '__main__': ["tiff", "Tag Image File Format (TIFF) library", [header_exists, "tiffio.h"], "", "-ltiff", ["loaders"]], - ["libX11", + ["zlib", + "Standard (de)compression library", + [header_exists, "zlib.h"], "", "-lz", ["loaders"]], + ["libX11", "X11 library", [header_exists, "X11/Xlib.h"], "", "-lX11", ["backends"]], ["X_SHM", diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile index e430cc4..3ed296b 100644 --- a/demos/c_simple/Makefile +++ b/demos/c_simple/Makefile @@ -18,7 +18,8 @@ APPS=backend_example loaders_example loaders filters_symmetry gfx_koch v4l2_show v4l2_grab convolution weighted_median shapetest koch input_example fileview linetest randomshapetest fonttest loaders_register blittest textaligntest abort sin_AA x11_windows- debug_handler gaussian_noise byte_utils version pretty_print timers + debug_handler gaussian_noise byte_utils version pretty_print timers+ zip_container
ifeq ($(HAVE_LIBSDL),yes) APPS+=SDL_glue @@ -54,6 +55,7 @@ byte_utils: LDLIBS+=$(LDLIBS_LOADERS) blittest: LDLIBS+=$(LDLIBS_BACKENDS) $(LDLIBS_LOADERS) sin_AA: LDLIBS+=$(LDLIBS_BACKENDS) x11_windows: LDLIBS+=$(LDLIBS_BACKENDS) +zip_container: LDLIBS+=$(LDLIBS_LOADERS) $(LDLIBS_BACKENDS)
include $(TOPDIR)/app.mk include $(TOPDIR)/post.mk diff --git a/demos/c_simple/zip_container.c b/demos/c_simple/zip_container.c new file mode 100644 index 0000000..6e24108 --- /dev/null +++ b/demos/c_simple/zip_container.c @@ -0,0 +1,134 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +/* + + Simple example that loads and show image from zip container into X11 window. + + */ + +#include <stdio.h> +#include <errno.h> +#include <string.h> + +#include <GP.h> + +static GP_Backend *backend; +static GP_Context *image; +static GP_Container *container; + +/* + * Try to load next image in container, if image has different size than the + * window request resize and blit it at the resize event in the main loop. + * + * Note that the resize event needs not to be granted so we really should have + * plan b (which is omited here for the sake of simplicity). + */ +static void load_next(void) +{ + GP_ContextFree(image); + + image = GP_ContainerLoadNext(container, NULL); + + if (image == NULL) + return; + + if (image->w != backend->context->w || + image->h != backend->context->h) { + GP_BackendResize(backend, image->w, image->h); + return; + } + + GP_Blit(image, 0, 0, image->w, image->h, backend->context, 0, 0); + GP_BackendFlip(backend); +} + +int main(int argc, char *argv[]) +{ + + if (argc != 2) { + fprintf(stderr, "Takes path to zip or cbz as an argumentn"); + return 1; + } + + /* Open zip container */ + container = GP_OpenZip(argv[1]); + + if (container == NULL) { + fprintf(stderr, "Failed to open container: %sn", strerror(errno)); + return 1; + } + + /* Load image */ + image = GP_ContainerLoadNext(container, NULL); + + if (image == NULL) { + fprintf(stderr, "Failed to load image %sn", strerror(errno)); + return 1; + } + + /* Initalize backend */ + backend = GP_BackendX11Init(NULL, 0, 0, image->w, image->h, argv[1], 0); + + if (backend == NULL) { + fprintf(stderr, "Failed to initalize backendn"); + return 1; + } + + /* Blit image into the window and show it */ + GP_Blit(image, 0, 0, image->w, image->h, backend->context, 0, 0); + GP_BackendFlip(backend); + + /* Wait for events */ + for (;;) { + GP_Event ev; + + GP_BackendWaitEvent(backend, &ev); + + switch (ev.type) { + case GP_EV_KEY: + if (!ev.code == GP_EV_KEY_DOWN) + continue; + + switch (ev.val.val) { + case GP_KEY_Q: + GP_BackendExit(backend); + return 0; + break; + case GP_KEY_SPACE: + load_next(); + break; + } + break; + case GP_EV_SYS: + if (ev.code == GP_EV_SYS_RESIZE) { + GP_BackendResizeAck(backend); + GP_Blit(image, 0, 0, image->w, image->h, + backend->context, 0, 0); + GP_BackendFlip(backend); + } + break; + } + } + + return 0; +} diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_Container.h similarity index 55% copy from include/loaders/GP_Loaders.h copy to include/loaders/GP_Container.h index 31066d3..36dafdf 100644 --- a/include/loaders/GP_Loaders.h +++ b/include/loaders/GP_Container.h @@ -16,37 +16,72 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
- Core include file for loaders API. + Container is an abstraction for file formats that can include several images + in one file. For example gif, tiff, apng, cbr, cbz, etc.
*/
-#ifndef LOADERS_GP_LOADERS_H -#define LOADERS_GP_LOADERS_H +#ifndef LOADERS_GP_CONTAINER_H +#define LOADERS_GP_CONTAINER_H
#include "core/GP_Context.h" #include "core/GP_ProgressCallback.h"
-#include "GP_PNM.h" -#include "GP_BMP.h" -#include "GP_PNG.h" -#include "GP_JPG.h" -#include "GP_GIF.h" -#include "GP_TIFF.h" -#include "GP_PSP.h" +struct GP_Container; + +struct GP_ContainerOps { + /* + * Loads next image from container, use the inline function defined + * bellow. + */ + GP_Context *(*LoadNext)(struct GP_Container *self, + GP_ProgressCallback *callback); + + /* + * Close callback, use the inline function defined bellow. + */ + void (*Close)(struct GP_Container *self); + + //TODO: Seek +}; + +typedef struct GP_Container { + /* + * Image counter. This is set to number of images, or to -1 if number + * of images in container is not known prior to parsing the whole + * file. + */ + int img_count; + /* + * Current image counter, do not change from application. + */ + int cur_img; + + const struct GP_ContainerOps *ops; + + char priv[]; +} GP_Container;
-#include "GP_TmpFile.h" +#define GP_CONTAINER_PRIV(c) ((void*)(c)->priv)
-#include "GP_MetaData.h" +/* + * Behaves just like GP_LoadImage, but takes pointer to opened container instead. + */ +static inline GP_Context *GP_ContainerLoadNext(GP_Container *self, + GP_ProgressCallback *callback) +{ + return self->ops->LoadNext(self, callback); +}
-#include "GP_Loader.h" +static inline void GP_ContainerClose(GP_Container *self) +{ + self->ops->Close(self); +}
-#endif /* LOADERS_GP_LOADERS_H */ +#endif /* LOADERS_GP_CONTAINER_H */ diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_Loaders.h index 31066d3..c9e9c49 100644 --- a/include/loaders/GP_Loaders.h +++ b/include/loaders/GP_Loaders.h @@ -35,18 +35,21 @@ #include "core/GP_Context.h" #include "core/GP_ProgressCallback.h"
-#include "GP_PNM.h" -#include "GP_BMP.h" -#include "GP_PNG.h" -#include "GP_JPG.h" -#include "GP_GIF.h" -#include "GP_TIFF.h" -#include "GP_PSP.h" +#include "loaders/GP_PNM.h" +#include "loaders/GP_BMP.h" +#include "loaders/GP_PNG.h" +#include "loaders/GP_JPG.h" +#include "loaders/GP_GIF.h" +#include "loaders/GP_TIFF.h" +#include "loaders/GP_PSP.h"
-#include "GP_TmpFile.h" +#include "loaders/GP_TmpFile.h"
-#include "GP_MetaData.h" +#include "loaders/GP_MetaData.h"
-#include "GP_Loader.h" +#include "loaders/GP_Loader.h" + +#include "loaders/GP_Container.h" +#include "loaders/GP_ZIP.h"
#endif /* LOADERS_GP_LOADERS_H */ diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_ZIP.h similarity index 74% copy from include/loaders/GP_Loaders.h copy to include/loaders/GP_ZIP.h index 31066d3..06031e9 100644 --- a/include/loaders/GP_Loaders.h +++ b/include/loaders/GP_ZIP.h @@ -16,37 +16,24 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
- Core include file for loaders API. + Zip container, could be used to load images from cbz or from zip files.
*/
-#ifndef LOADERS_GP_LOADERS_H -#define LOADERS_GP_LOADERS_H +#ifndef LOADERS_GP_ZIP_H +#define LOADERS_GP_ZIP_H
#include "core/GP_Context.h" #include "core/GP_ProgressCallback.h"
-#include "GP_PNM.h" -#include "GP_BMP.h" -#include "GP_PNG.h" -#include "GP_JPG.h" -#include "GP_GIF.h" -#include "GP_TIFF.h" -#include "GP_PSP.h" - -#include "GP_TmpFile.h" - -#include "GP_MetaData.h" +#include "loaders/GP_Container.h"
-#include "GP_Loader.h" +GP_Container *GP_OpenZip(const char *path);
-#endif /* LOADERS_GP_LOADERS_H */ +#endif /* LOADERS_GP_ZIP_H */ diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c new file mode 100644 index 0000000..c5ab037 --- /dev/null +++ b/libs/loaders/GP_ZIP.c @@ -0,0 +1,437 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <stdint.h> +#include <inttypes.h> + +#include "../../config.h" + +#ifdef HAVE_ZLIB + +#include <zlib.h> + +#endif /* HAVE_ZLIB */ + +#include "core/GP_Debug.h" + +#include "loaders/GP_ByteUtils.h" +#include "loaders/GP_JPG.h" + +#include "loaders/GP_ZIP.h" + +#ifdef HAVE_ZLIB + +#define GEN_FLAG_ENCRYPTED 0x01 + +struct zip_local_header { + uint16_t ver; + uint16_t bit_flags; + uint16_t comp_type; + + uint32_t crc; + uint32_t comp_size; + uint32_t uncomp_size; + + char *file_name; +}; + +enum compress_method { + COMPRESS_STORED = 0x00, /* no compression at all */ + COMPRESS_SHRUNK = 0x01, + COMPRESS_REDUCE1 = 0x02, + COMPRESS_REDUCE2 = 0x03, + COMPRESS_REDUCE3 = 0x04, + COMPRESS_REDUCE4 = 0x05, + COMPRESS_IMPLODE = 0x06, + COMPRESS_RESERVED1 = 0x07, + COMPRESS_DEFLATE = 0x08, + COMPRESS_DEFLATE64 = 0x09, + COMPRESS_PKWARE_IMPLODE = 0x0a, + COMPRESS_RESERVED2 = 0x0b, + COMPRESS_BZIP2 = 0x0c, +}; + +const char *compress_method_names[] = { + "Stored (no compression)", + "Shrunk", + "Reduced with factor 1", + "Reduced with factor 2", + "Reduced with factor 3", + "Reduced with factor 4", + "Imploded", + "Reserved 1", + "Deflate", + "Deflate64", + "PKWARE Implode", + "Reserved 2", + "BZIP2", +}; + +static const char *compress_method_name(enum compress_method comp) +{ + if (comp > COMPRESS_BZIP2) + return "Unknown"; + + return compress_method_names[comp]; +} + +static int seek_bytes(FILE *f, uint32_t bytes) +{ + if (bytes == 0) + return 0; + + GP_DEBUG(4, "Moving forward by %"PRIu32"bytes", bytes); + + if (fseek(f, bytes, SEEK_CUR)) { + int err = errno; + GP_DEBUG(1, "Failed to seek: %s", strerror(errno)); + return err; + } + + return 0; +} + +static void read_stored(FILE *f, struct zip_local_header *header) +{ + /* ignored for now */ + seek_bytes(f, header->uncomp_size); +} + +#define CHUNK 512 + +struct deflate_inbuf { + struct zip_local_header *zip_header; + uint32_t to_read; + unsigned char buf[CHUNK]; + FILE *f; +}; + +struct deflate_outbuf { + uint32_t crc; + uint32_t size; + FILE *f; +}; + +static unsigned deflate_in(void *in_desc, unsigned char **buf) +{ + struct deflate_inbuf *in = in_desc; + uint32_t chunk = in->to_read >= CHUNK ? CHUNK : in->to_read; + + if (fread(in->buf, chunk, 1, in->f) != 1) + return 0; + + *buf = in->buf; + in->to_read -= chunk; + + return chunk; +} + +static int deflate_out(void *out_desc, unsigned char *buf, unsigned len) +{ + struct deflate_outbuf *out = out_desc; + + out->crc = crc32(out->crc, buf, len); + out->size += len; + + if (fwrite(buf, len, 1, out->f) != 1) { + GP_DEBUG(1, "Failed to write temp file"); + return 1; + } + + return 0; +} + +static int read_deflate(FILE *f, struct zip_local_header *header, FILE **res_f) +{ + uint8_t *window; + int err = 0, ret; + FILE *tf; + + tf = tmpfile(); + + if (!tf) { + err = errno; + GP_DEBUG(1, "Failed to create temp file"); + return err; + } + + window = malloc(32 * 1024); + + if (!window) { + err = ENOMEM; + goto err0; + } + + z_stream strm = { + .zalloc = Z_NULL, + .zfree = Z_NULL, + .opaque = Z_NULL, + .next_in = Z_NULL, + }; + + if (inflateBackInit(&strm, 15, window) != Z_OK) { + GP_DEBUG(1, "Failed to initialize inflate stream"); + //TODO: Better errno? + err = EIO; + goto err1; + } + + struct deflate_outbuf outbuf = { + .crc = crc32(0, NULL, 0), + .size = 0, + .f = tf, + }; + + struct deflate_inbuf inbuf = { + .zip_header = header, + .f = f, + .to_read = header->comp_size, + }; + + ret = inflateBack(&strm, deflate_in, &inbuf, deflate_out, &outbuf); + + if (ret != Z_STREAM_END) { + GP_DEBUG(1, "Failed to inflate stream %i", ret); + errno = EINVAL; + goto err2; + } + + if (outbuf.crc != header->crc) { + GP_DEBUG(1, "CRC does not match"); + err = EIO; + goto err2; + } + + if (outbuf.size != header->uncomp_size) { + GP_DEBUG(1, "Decompressed size does not match"); + err = EIO; + goto err2; + } + + rewind(tf); + *res_f = tf; + return 0; +err2: + inflateBackEnd(&strm); +err1: + free(window); +err0: + fclose(tf); + return err; +} + +static int zip_next_file(FILE *f, FILE **res) +{ + uint16_t fname_len, extf_len; + struct zip_local_header header = {.file_name = NULL}; + int ret, err = 0; + + ret = GP_FRead(f, "0x50 0x4b 0x03 0x04 L2 L2 L2 I4 L4 L4 L4 L2 L2", + &header.ver, &header.bit_flags, &header.comp_type, + &header.crc, &header.comp_size, &header.uncomp_size, + &fname_len, &extf_len); + + if (ret != 13) { + GP_DEBUG(1, "Failed to read header"); + return EIO; + } + + GP_DEBUG(1, "Have ZIP local header version %u.%u compression %s", + header.ver/10, header.ver%10, + compress_method_name(header.comp_type)); + + if (header.bit_flags & GEN_FLAG_ENCRYPTED) { + GP_DEBUG(1, "Can't handle encrypted files"); + return ENOSYS; + } + + /* + * If input was taken from stdin the fname_len is either set to zero or + * to one and filename is set to '-'. + */ + if (fname_len) { + header.file_name = malloc(fname_len + 1); + + if (!header.file_name) + return ENOMEM; + + header.file_name[fname_len] = '0'; + + if (fread(header.file_name, fname_len, 1, f) != 1) { + GP_DEBUG(1, "Failed to read filename"); + err = EIO; + goto err0; + } + + GP_DEBUG(1, "Filename '%s' compressed size=%"PRIu32 + " uncompressed size=%"PRIu32, + header.file_name, header.comp_size, + header.uncomp_size); + } + + seek_bytes(f, extf_len); + + switch (header.comp_type) { + case COMPRESS_STORED: + read_stored(f, &header); + break; + case COMPRESS_DEFLATE: + read_deflate(f, &header, res); + break; + default: + GP_DEBUG(1, "Unimplemented compression %s", + compress_method_name(header.comp_type)); + return ENOSYS; + } + + return 0; +err0: + free(header.file_name); + return err; +} + +struct zip_priv { + FILE *f; +}; + +static GP_Context *zip_load_next(GP_Container *self, + GP_ProgressCallback *callback) +{ + struct zip_priv *priv = GP_CONTAINER_PRIV(self); + FILE *res = NULL; + GP_Context *ret; + int err; + + GP_DEBUG(1, "Trying to load next image from ZIP container"); + + do + err = zip_next_file(priv->f, &res); + while (!err && !res); + + if (err) { + errno = err; + return NULL; + } + + ret = GP_ReadJPG(res, callback); + err = errno; + fclose(res); + errno = err; + + return ret; +} + +static void zip_close(GP_Container *self) +{ + struct zip_priv *priv = GP_CONTAINER_PRIV(self); + + GP_DEBUG(1, "Closing ZIP container"); + + fclose(priv->f); + free(self); +} + + +static int open_zip(const char *path, FILE **file) +{ + FILE *f; + int err = 0; + + f = fopen(path, "rb"); + + if (f == NULL) { + err = errno; + GP_DEBUG(1, "Failed to open '%s': %s", path, strerror(errno)); + if (!err) + err = EIO; + return err; + } + + /* Check zip local file header and seek back */ + if (GP_FRead(f, "0x50 0x4b 0x03 0x04") != 4) { + GP_DEBUG(1, "Invalid zip header"); + err = EINVAL; + goto err0; + } + + rewind(f); + + *file = f; + return 0; +err0: + fclose(f); + return err; +} + +static const struct GP_ContainerOps zip_ops = { + .LoadNext = zip_load_next, + .Close = zip_close, +}; + +GP_Container *GP_OpenZip(const char *path) +{ + struct zip_priv *priv; + GP_Container *ret; + FILE *f; + int err; + + if ((err = open_zip(path, &f))) { + errno = err; + return NULL; + } + + ret = malloc(sizeof(GP_Container) + sizeof(struct zip_priv)); + + if (!ret) { + err = ENOMEM; + goto err0; + } + + priv = GP_CONTAINER_PRIV(ret); + + priv->f = f; + + ret->img_count = -1; + ret->cur_img = 0; + ret->ops = &zip_ops; + + return ret; +err0: + fclose(f); + errno = err; + return NULL; +} + +#else + +GP_Container *GP_OpenZip(const char *path) +{ + GP_FATAL("zlib support not compiled in"); + errno = ENOSYS; + return NULL; +} + +#endif /* HAVE_ZLIB */ +
http://repo.or.cz/w/gfxprim.git/commit/86c1e0faccd6228843fa35d6f7f2bf54ab57f...
commit 86c1e0faccd6228843fa35d6f7f2bf54ab57fa11 Author: Cyril Hrubis metan@ucw.cz Date: Tue Jul 9 20:03:34 2013 +0200
loaders: ByteUtils: Correct comments in header.
The comments in the header were wrongly defining the return value as a number of bytes instead of number of sucesful conversions.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/loaders/GP_ByteUtils.h b/include/loaders/GP_ByteUtils.h index 8a26e9c..8916fd7 100644 --- a/include/loaders/GP_ByteUtils.h +++ b/include/loaders/GP_ByteUtils.h @@ -22,7 +22,7 @@
/*
- Utils to read/write bytes in specified endianity. + Utils to read/write values with specified endianity.
*/
@@ -58,16 +58,16 @@ */
/* - * Printf-like function to read bytes from a file. + * Printf-like function to read file headers. * - * Returns number of characters read. + * Returns number of items successfully matched/converted. */ int GP_FRead(FILE *f, const char *fmt, ...);
/* - * Printf-like function to write bytes to a file. + * Printf-like function to write file headers. * - * Returns number of characters read. + * Returns number of items sucessfully written. */ int GP_FWrite(FILE *f, const char *fmt, ...);
http://repo.or.cz/w/gfxprim.git/commit/475c56e9cccddae51438fec2b1ddfb546fa8b...
commit 475c56e9cccddae51438fec2b1ddfb546fa8b20a Author: Cyril Hrubis metan@ucw.cz Date: Tue Jul 9 18:55:31 2013 +0200
doc: compilation: Add libtiff to additional deps
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/compilation.txt b/doc/compilation.txt index 1ae82f6..bd8a1b3 100644 --- a/doc/compilation.txt +++ b/doc/compilation.txt @@ -18,6 +18,7 @@ Image loaders * libjpeg * libpng * giflib +* libtiff
Text rendering ^^^^^^^^^^^^^^ @@ -79,7 +80,7 @@ zypper in gcc make python-jinja2
.Install jpeg and png devel libraries ------------------------------------------------------------------------------- -zypper in libjpeg-devel libpng-devel giflib-devel +zypper in libjpeg-devel libpng-devel giflib-devel libtiff-devel -------------------------------------------------------------------------------
.Install FreeType devel library @@ -100,14 +101,15 @@ zypper in swig python-devel .All in the one for the lazy ------------------------------------------------------------------------------- zypper in gcc make python-Jinja2 libjpeg-devel libpng-devel giflib-devel - freetype-devel libX11-devel libXext-devel swig python-devel + libtiff-devel freetype-devel libX11-devel libXext-devel swig + python-devel -------------------------------------------------------------------------------
Debian ~~~~~~
Instruction to install required packages on link:http://www.debian.org%5BDebian] -and other debian based distributions. +and other Debian based distributions.
.Install basic tools ------------------------------------------------------------------------------- @@ -116,7 +118,7 @@ apt-get install gcc make python-jinja2
.Install jpeg and png devel libraries ------------------------------------------------------------------------------- -apt-get install libjpeg-dev libpng-dev libgif-dev +apt-get install libjpeg-dev libpng-dev libgif-dev libtiff-dev -------------------------------------------------------------------------------
.Install FreeType devel library @@ -137,5 +139,6 @@ apt-get install swig python-dev .All in the one for the lazy ------------------------------------------------------------------------------- apt-get install gcc make python-jinja2 libjpeg-dev libpng-dev libgif-dev - libfreetype6-dev libx11-dev libxext-dev swig python-dev + libtiff-dev libfreetype6-dev libx11-dev libxext-dev swig + python-dev -------------------------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes: configure | 5 +- demos/c_simple/Makefile | 4 +- demos/c_simple/{showimage.c => zip_container.c} | 76 +++- demos/spiv/spiv.c | 11 +- doc/compilation.txt | 13 +- include/core/GP_Threads.h | 2 +- include/loaders/GP_ByteUtils.h | 10 +- include/loaders/{GP_PNM.h => GP_Container.h} | 93 +++-- include/loaders/GP_Loaders.h | 23 +- include/{filters/GP_Filter.h => loaders/GP_ZIP.h} | 18 +- libs/loaders/GP_ZIP.c | 437 +++++++++++++++++++++ 11 files changed, 598 insertions(+), 94 deletions(-) copy demos/c_simple/{showimage.c => zip_container.c} (58%) copy include/loaders/{GP_PNM.h => GP_Container.h} (55%) copy include/{filters/GP_Filter.h => loaders/GP_ZIP.h} (84%) create mode 100644 libs/loaders/GP_ZIP.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.