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 c4cb658954c2cd3de44939d096b48eb40438d674 (commit) via 623d537b03153f26c9e6cc0d68d7dfa70fb62058 (commit) via e78aa462e49f391bc0cf7fc31bde121063e23f2c (commit) via 556a69a3e1bb48998da72d810b8daec1af997f49 (commit) via 9bf5488c204dba601b1f43ab1a20542207f194be (commit) from 05ec5cc78e822d2d4d45b54280997526d5e1bd64 (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/c4cb658954c2cd3de44939d096b48eb40438d...
commit c4cb658954c2cd3de44939d096b48eb40438d674 Author: Cyril Hrubis metan@ucw.cz Date: Tue Mar 18 23:31:08 2014 +0100
loaders: zip: Partial support for stream zip
Some zip files does not have crc, compressed size and uncompressed size in zip local header but in data descriptor (which is located after the data).
This commit modifies the decompression rutines to cope with unknown buffer size (the buffer is reallocated on the fly).
Seeking in the ZIP does not work yet.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c index 11e3eed6..7928023d 100644 --- a/libs/loaders/GP_ZIP.c +++ b/libs/loaders/GP_ZIP.c @@ -177,30 +177,50 @@ struct deflate_inbuf { struct deflate_outbuf { uint32_t crc; uint32_t size; + uint32_t fill; uint8_t *buf; };
static unsigned deflate_in(void *in_desc, unsigned char **buf) { struct deflate_inbuf *in = in_desc; - int chunk = in->to_read >= CHUNK ? CHUNK : in->to_read; + int chunk, ret;
- if (GP_IORead(in->io, in->buf, chunk) != chunk) - return 0; + if (in->to_read) + chunk = in->to_read >= CHUNK ? CHUNK : in->to_read; + else + chunk = CHUNK; + + ret = GP_IORead(in->io, in->buf, chunk); + + if (ret <= 0) + return ret;
*buf = in->buf; - in->to_read -= chunk;
- return chunk; + if (in->to_read) + in->to_read -= ret; + + return ret; }
+#define BUFINC (1024 * 128) + static int deflate_out(void *out_desc, unsigned char *buf, unsigned len) { struct deflate_outbuf *out = out_desc;
+ if (out->fill + len >= out->size) { + out->buf = realloc(out->buf, out->size + GP_MAX(len, BUFINC)); + if (!out->buf) + return 1; + out->size += GP_MAX(len, BUFINC); + GP_DEBUG(1, "Realloc %u %p", out->size, out->buf); + } + out->crc = crc32(out->crc, buf, len); - memcpy(out->buf + out->size, buf, len); - out->size += len; + memcpy(out->buf + out->fill, buf, len); + out->fill += len;
return 0; } @@ -210,16 +230,12 @@ static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio) uint8_t *window; int err = 0, ret; uint8_t *buf; - - if (header->flags & FLAG_ZERO_SIZE_CRC) { - GP_DEBUG(1, "Size not set in local file header"); - return ENOSYS; - } + unsigned int bufsize = header->uncomp_size ? header->uncomp_size : BUFINC;
window = malloc(32 * 1024);
//TODO: Unsafe - buf = malloc(header->uncomp_size); + buf = malloc(bufsize);
if (!window || !buf) { err = ENOMEM; @@ -242,7 +258,8 @@ static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio)
struct deflate_outbuf outbuf = { .crc = crc32(0, NULL, 0), - .size = 0, + .size = bufsize, + .fill = 0, .buf = buf, };
@@ -260,13 +277,31 @@ static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio) goto err2; }
+ if (header->flags & FLAG_ZERO_SIZE_CRC) { + GP_DEBUG(2, "In buffer %i, seeking back", strm.avail_in); + GP_IOSeek(io, -(int)strm.avail_in, GP_IO_SEEK_CUR); + uint16_t data_desc_header[] = { + 'P', 'K', 0x07, 0x08, /* Data desc header */ + GP_IO_L4, /* CRC */ + GP_IO_L4, /* Compressed size */ + GP_IO_L4, /* Uncompressed size */ + GP_IO_END + }; + + if (GP_IOReadF(io, data_desc_header, &header->crc, + &header->comp_size, &header->uncomp_size) != 7) { + GP_DEBUG(1, "Failed to read Data Description Header"); + goto err2; + } + } + if (outbuf.crc != header->crc) { GP_DEBUG(1, "CRC does not match"); err = EIO; goto err2; }
- if (outbuf.size != header->uncomp_size) { + if (outbuf.fill != header->uncomp_size) { GP_DEBUG(1, "Decompressed size does not match"); err = EIO; goto err2; @@ -282,7 +317,7 @@ err2: inflateBackEnd(&strm); err1: free(window); - free(buf); + free(outbuf.buf); return err; }
http://repo.or.cz/w/gfxprim.git/commit/623d537b03153f26c9e6cc0d68d7dfa70fb62...
commit 623d537b03153f26c9e6cc0d68d7dfa70fb62058 Author: Cyril Hrubis metan@ucw.cz Date: Tue Mar 18 19:42:20 2014 +0100
loaders: zip: Add flag defs.
Add flags definitions and print them to debug output.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c index ec80e963..11e3eed6 100644 --- a/libs/loaders/GP_ZIP.c +++ b/libs/loaders/GP_ZIP.c @@ -73,11 +73,9 @@ struct zip_priv { struct zip_chunks_table table; };
-#define GEN_FLAG_ENCRYPTED 0x01 - struct zip_local_header { uint16_t ver; - uint16_t bit_flags; + uint16_t flags; uint16_t comp_type;
uint32_t crc; @@ -130,6 +128,27 @@ static const char *compress_method_name(enum compress_method comp) return compress_method_names[comp]; }
+enum zip_flags { + /* File is encrypted */ + FLAG_ENCRYPTED = 0x0001, + /* Size and CRC are in data descriptor after the compressed data */ + FLAG_ZERO_SIZE_CRC = 0x0008, + /* Filename and comment fileds are in UTF-8 */ + FLAG_UTF8 = 0x0800, +}; + +static void print_flags(struct zip_local_header *header) +{ + if (header->flags & FLAG_ENCRYPTED) + GP_DEBUG(2, "File is encrypted"); + + if (header->flags & FLAG_ZERO_SIZE_CRC) + GP_DEBUG(2, "File size and CRC are after compressed data"); + + if (header->flags & FLAG_UTF8) + GP_DEBUG(2, "Filename and comment are encoded in UTF-8"); +} + static int seek_bytes(GP_IO *io, uint32_t bytes) { if (bytes == 0) @@ -192,7 +211,13 @@ static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio) int err = 0, ret; uint8_t *buf;
+ if (header->flags & FLAG_ZERO_SIZE_CRC) { + GP_DEBUG(1, "Size not set in local file header"); + return ENOSYS; + } + window = malloc(32 * 1024); + //TODO: Unsafe buf = malloc(header->uncomp_size);
@@ -307,7 +332,7 @@ static int zip_load_header(GP_IO *io, struct zip_local_header *header) };
ret = GP_IOReadF(io, zip_local_header, - &header->ver, &header->bit_flags, &header->comp_type, + &header->ver, &header->flags, &header->comp_type, &header->crc, &header->comp_size, &header->uncomp_size, &header->fname_len, &header->extf_len);
@@ -334,7 +359,9 @@ static GP_Context *zip_next_file(struct zip_priv *priv, header.ver/10, header.ver%10, compress_method_name(header.comp_type));
- if (header.bit_flags & GEN_FLAG_ENCRYPTED) { + print_flags(&header); + + if (header.flags & FLAG_ENCRYPTED) { GP_DEBUG(1, "Can't handle encrypted files"); err = ENOSYS; goto out;
http://repo.or.cz/w/gfxprim.git/commit/e78aa462e49f391bc0cf7fc31bde121063e23...
commit e78aa462e49f391bc0cf7fc31bde121063e23f2c Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 16 21:51:13 2014 +0100
doc: Update compilation instructions
* Add links to libraries
* Add packages section
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/compilation.txt b/doc/compilation.txt index b5eb7fc4..35f8bd8a 100644 --- a/doc/compilation.txt +++ b/doc/compilation.txt @@ -3,33 +3,35 @@ Dependencies
*Base dependencies*
-* C compiler (tested with 'gcc' or 'clang') -* GNU make -* Python (2.6 or newer) -* Jinja2 +* C compiler (tested with link:http://gcc.gnu.org/%5Bgcc] and + link:http://clang.llvm.org/%5Bclang]) +* link:https://www.gnu.org/software/make/%5BGNU make] +* link:https://www.python.org/%5BPython] (2.6 or newer) +* link:http://jinja.pocoo.org/docs/%5BJinja2]
*Optional Image loaders*
* libjpeg -* libpng -* giflib -* libtiff -* openjpeg >= 2.0.0 -* zlib (usually installed as libpng dependency) +* link:http://www.libpng.org/%5Blibpng] +* link:http://sourceforge.net/projects/giflib/%5Bgiflib] +* link:http://www.remotesensing.org/libtiff/%5Blibtiff] +* link:http://code.google.com/p/openjpeg/%5Bopenjpeg] >= 2.0.0 +* link:http://www.zlib.net/%5Bzlib] (usually installed as libpng dependency)
*Optinal Text rendering*
-* FreeType +* link:http://www.freetype.org/%5BFreeType]
*Optional Backends*
* X11 -* AA-lib -* SDL-1.2 (not recomended, known to be slow and buggy) +* link:http://aa-project.sourceforge.net/aalib/%5BAA-lib] +* link:http://www.libsdl.org/%5BSDL] 1.2 + (not recomended, known to be slow and buggy)
*Python Bindings*
-* Swig +* link:http://www.swig.org/%5BSwig] * Python (devel library)
Compilation @@ -61,7 +63,7 @@ The +make install+ command will install GFXprim libraries and devel headers into your system.
OpenSUSE & Fedora ------------------ +~~~~~~~~~~~~~~~~~
Instruction to install required packages on link:http://www.opensuse.org/%5BOpenSUSE]. @@ -102,7 +104,7 @@ zypper in gcc make python-Jinja2 libjpeg-devel libpng-devel giflib-devel -------------------------------------------------------------------------------
Debian ------- +~~~~~~
Instruction to install required packages on link:http://www.debian.org%5BDebian] and other Debian based distributions. @@ -138,3 +140,27 @@ apt-get install gcc make python-jinja2 libjpeg-dev libpng-dev libgif-dev libtiff-dev libfreetype6-dev libx11-dev libxext-dev swig python-dev ------------------------------------------------------------------------------- + +Packages +-------- + +RPM +~~~ +RPM packages as well as specfile are available in +link:https://build.opensuse.org/package/show/home:metan/gfxprim%5Bbuild service]. + +Deb +~~~ +Deb packages can be build from the GFXprim source (after installing necessary +devel packages) by: + +.Building debian packages +------------------------------------------------------------------------------- +# apt-get install devscripts +# cd gfxprim +# debuild -i -us -uc +------------------------------------------------------------------------------- + +Gentoo +~~~~~~ +GFXprim source contains ebuild in 'gentoo/' directory.
http://repo.or.cz/w/gfxprim.git/commit/556a69a3e1bb48998da72d810b8daec1af997...
commit 556a69a3e1bb48998da72d810b8daec1af997f49 Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 16 21:19:48 2014 +0100
doc: Remove '' from emphasized words, fixes.
* NULL, stderr, stdout... are now emphasized by default
* A few fixes
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/backends.txt b/doc/backends.txt index 4196c8f8..9b0c392c 100644 --- a/doc/backends.txt +++ b/doc/backends.txt @@ -124,9 +124,9 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y, enum GP_BackendX11Flags flags); -------------------------------------------------------------------------------
-Returns pointer to initialized X11 backend or in case of failure 'NULL'. +Returns pointer to initialized X11 backend or in case of failure NULL.
-When display is 'NULL' default display is used (which is what you want most of the +When display is NULL default display is used (which is what you want most of the time).
This backends supports multiple windows. Each time you call the initialization @@ -217,11 +217,11 @@ The 'caption' string is used for window caption, in case of X11 backend or may be ignored completly in case of framebuffer backend.
If 'params' is set to '"help"' help for all backends is printed into the -'stderr'. +stderr.
If initialization was successful pointer to allocated and initialized backend -is returned otherwise 'NULL' is returned and some helpful information should -be printed into the 'stderr'. +is returned otherwise NULL is returned and some helpful information should +be printed into the stderr.
General Backend API @@ -458,7 +458,7 @@ Adds a link:input.html#Timers[timer] to the backend timer queue. Timers added to the backend are processed automatically while you call any of backend 'Poll' or 'Wait' functions.
-If timer callback is set to 'NULL' a timer event is pushed to the backend +If timer callback is set to NULL a timer event is pushed to the backend input queue once timer has expired otherwise timer callback is called.
TIP: For example usage see backend timers diff --git a/doc/context.txt b/doc/context.txt index b8213ffe..c59c714e 100644 --- a/doc/context.txt +++ b/doc/context.txt @@ -44,8 +44,8 @@ lines (i.e. each image line starts at whole byte and ends at whole byte).
The 'pixels' array starts exactly at upper left corner of the image and is stored in horizontal lines (each line contains 'w' pixels and there is 'h' -lines). Each line is 'bytes_per_row' bytes long (which equals to 'w' * 'bpp' / -8 rouned up to the whole bytes). The first pixel may actually start at +lines). Each line is 'bytes_per_row' bytes long (which equals to 'w * bpp / +8' rouned up to the whole bytes). The first pixel may actually start at 'offset' bit in the first byte in each line (but only for some <<Sub_Context,subcontexts>> for pixel types that are not byte aligned).
@@ -153,7 +153,7 @@ parameters are set to the default values (i.e. rotation flags are all set to zero, 'free_pixels' flag is not set). Number of bits per pixel and bytes per row are computed from the given pixel type and size.
-The 'pixels' pointer can be 'NULL' and can be changed later manually (the call +The 'pixels' pointer can be NULL and can be changed later manually (the call will *not* try to allocate the pixel memory automatically).
The function returns a pointer to the initialized context (i.e. the same @@ -224,7 +224,7 @@ Frees the context memory.
If 'free_pixels' flag is set, the pixels buffer is freed too.
-If gamma pointer is not 'NULL' the 'GP_GammaRelease()' is called. +If gamma pointer is not NULL the 'GP_GammaRelease()' is called.
[[Sub_Context]] Subcontext diff --git a/doc/debug.txt b/doc/debug.txt index 7424064f..e5f0015e 100644 --- a/doc/debug.txt +++ b/doc/debug.txt @@ -69,7 +69,7 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line, Printf-like macros used to print debug messages. All of them calls the 'GP_DebugPrint()' function with slightly different parameters.
-NOTE: 'GP_DebugPrint()' function preserves 'errno'. +NOTE: 'GP_DebugPrint()' function preserves errno.
[source,c] ------------------------------------------------------------------------------- @@ -101,7 +101,7 @@ void GP_SetDebugHandler(void (*handler)(const struct GP_DebugMsg *msg));
-------------------------------------------------------------------------------
-By default debug messages are printed into the 'stderr' you can redirect them +By default debug messages are printed into the stderr you can redirect them to your debug handler by this function.
NOTE: For more information see debug message handler diff --git a/doc/environment_variables.txt b/doc/environment_variables.txt index 26d72095..85b6758d 100644 --- a/doc/environment_variables.txt +++ b/doc/environment_variables.txt @@ -37,7 +37,7 @@ messages are printed. Current the maximum used in GFXprim sources is 4, this may change in the future. Use 'GP_DEBUG=10' to enable all debug messages for sure.
-The output is, by default, written to 'stderr' and will look like: +The output is, by default, written to stderr and will look like: ------------------------------------------------------------------------------ 1: GP_Debug.c:GP_DebugPrint():67: Using debug level GP_DEBUG=10 from enviroment variable 1: GP_Debug.c:GP_DebugPrint():71: GFXprim library version 1.0.0-rc0 diff --git a/doc/event_queue.txt b/doc/event_queue.txt index 5b476bd8..b694dc79 100644 --- a/doc/event_queue.txt +++ b/doc/event_queue.txt @@ -46,7 +46,7 @@ The initialization functions takes pointer to a memory large enough to hold an event queue structure and array of queue_size events.
The last function allocates and initializes an event queue. If allocation has -failed 'NULL' is returned. +failed NULL is returned.
[source,c] ------------------------------------------------------------------------------- @@ -153,5 +153,5 @@ void GP_EventQueuePush(struct GP_EventQueue *self, -------------------------------------------------------------------------------
Following functions are used for puting events into the event queue. If -pointer to the timeval structure is 'NULL' the event 'time' will be filled +pointer to the timeval structure is NULL the event 'time' will be filled with exact time the event was added to the queue. diff --git a/doc/filters.txt b/doc/filters.txt index 8cedbf9b..1ed37f09 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -22,12 +22,12 @@ For convenience, the filters API is unified: * And the last argument is link:progress_callback.html[progress callback]
When using allocating version of the filter, pointer to the newly allocated -context is returned, or in case of failure 'NULL' is returned. +context is returned, or in case of failure NULL is returned.
-If 'malloc()' has failed 'NULL' is returned. +If 'malloc()' has failed NULL is returned.
If filter has been interrupted by a callback, all allocated memory is freed, -and 'NULL' is returned. +and NULL is returned.
When using non-allocating variant of the filter, the destination context must have correct pixel type and the size must be big enough to store the result. diff --git a/doc/filters_dithering.txt b/doc/filters_dithering.txt index 2f2605b3..94c82033 100644 --- a/doc/filters_dithering.txt +++ b/doc/filters_dithering.txt @@ -52,11 +52,11 @@ GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src,
Returns pointer to allocated context of given pixel_type.
-If 'malloc(2)' has failed, or operation was aborted by a callback 'NULL' is +If 'malloc(2)' has failed, or operation was aborted by a callback NULL is returned.
Not all pixel types all supported. If particular combination is not supported -the function returns 'NULL' and sets errno to 'ENOSYS'. +the function returns NULL and sets errno to 'ENOSYS'.
Hilbert-Peano ~~~~~~~~~~~~~ @@ -85,7 +85,7 @@ destination must be at least as large as source. If operation was aborted by a callback, non-zero is returned.
Not all pixel types all supported. If particular combination is not supported -the function returns 'NULL' and sets errno to 'ENOSYS'. +the function returns NULL and sets errno to 'ENOSYS'.
[source,c] ------------------------------------------------------------------------------- @@ -100,11 +100,11 @@ GP_Context *GP_FilterHilbertPeanoAlloc(const GP_Context *src,
Returns pointer to allocated context of given pixel_type.
-If 'malloc(2)' has failed, or operation was aborted by a callback 'NULL' is +If 'malloc(2)' has failed, or operation was aborted by a callback NULL is returned.
Not all pixel types all supported. If particular combination is not supported -the function returns 'NULL' and sets errno to 'ENOSYS'. +the function returns NULL and sets errno to 'ENOSYS'.
include::images/convert/images.txt[] include::images/floyd_steinberg/images.txt[] diff --git a/doc/filters_python.txt b/doc/filters_python.txt index 19d50cf8..c1dadb84 100644 --- a/doc/filters_python.txt +++ b/doc/filters_python.txt @@ -8,7 +8,7 @@ The filter functions could be called directly as +filters.Foo(img, ..)+ or from submodule as +img.filters.Foo(..)+. Note that in the second case the image is passed automatically as a first parameter.
-If filter has been aborted from callback 'OSError' with 'errno' set to +If filter has been aborted from callback 'OSError' with errno set to 'ECANCELED' is raised, see progress callback link:core_python.html#Progress_Callback[documentation] for more information.
diff --git a/doc/filters_resize.txt b/doc/filters_resize.txt index 03310775..6cf65644 100644 --- a/doc/filters_resize.txt +++ b/doc/filters_resize.txt @@ -42,15 +42,15 @@ The +GP_FilterReize()+ function resizes 'src' to fit 'dst' exactly.
Both 'src' and 'dst' must have the same pixel type.
-Returns zero on success, non-zero on failure and sets 'errno'. +Returns zero on success, non-zero on failure and sets errno.
GP_FilterResizeAlloc ^^^^^^^^^^^^^^^^^^^^
The +GP_FilterResizeAlloc()+ allocates the destination give it's size.
-Returns pointer to newly allocated context or 'NULL' in case of failure and -'errno' is set. +Returns pointer to newly allocated context or NULL in case of failure and +errno is set.
Nearest Neighbour Interpolation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/gamma.txt b/doc/gamma.txt index 317900ae..a38518bd 100644 --- a/doc/gamma.txt +++ b/doc/gamma.txt @@ -109,7 +109,7 @@ Returns pointer to gamma table for particular pixel_type and gamma value.
The same gamma is used for all channels.
-May fail and return 'NULL' if 'malloc()' has failed. +May fail and return NULL if 'malloc()' has failed.
[source,c] ------------------------------------------------------------------------------- diff --git a/doc/grabbers.txt b/doc/grabbers.txt index 06ff7913..21285921 100644 --- a/doc/grabbers.txt +++ b/doc/grabbers.txt @@ -124,5 +124,5 @@ that width and height, but the driver may return different values if chosen width and height are not supported.
Returns either pointer to the initialized grabber or, in case of failure, -'NULL' and 'errno' is set. +NULL and errno is set.
diff --git a/doc/input.txt b/doc/input.txt index 08b0816d..13299979 100644 --- a/doc/input.txt +++ b/doc/input.txt @@ -191,7 +191,7 @@ Event API void GP_EventDump(struct GP_Event *ev); -------------------------------------------------------------------------------
-The 'GP_EventDump' dumps event in human-readable format into the 'stdout'. +The 'GP_EventDump' dumps event in human-readable format into the stdout.
[source,c] ------------------------------------------------------------------------------- diff --git a/doc/loaders.txt b/doc/loaders.txt index 7d43aa8a..c1d94e8e 100644 --- a/doc/loaders.txt +++ b/doc/loaders.txt @@ -73,7 +73,7 @@ functions for each format that implements signature matching. If image signature is recognized, image loader it is called and the result is returned.
If file extension disagrees with file signature (which is quite common on the -internet) a warning is printed into the 'stderr'. +internet) a warning is printed into the stderr.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. diff --git a/doc/loaders_io.txt b/doc/loaders_io.txt index e12e7468..2e010bbc 100644 --- a/doc/loaders_io.txt +++ b/doc/loaders_io.txt @@ -57,7 +57,7 @@ case of failure a negative number (-1).
Return value from 'Close' is zero on success and non-zero on IO failure.
-NOTE: Make sure 'errno' is set if any of the operations has failed. +NOTE: Make sure errno is set if any of the operations has failed.
[source,c] ------------------------------------------------------------------------------- @@ -73,7 +73,7 @@ This is a wrapper to 'io->Read()'. Reads at most 'size' bytes from an 'IO' stream and stores them into the buffer. Returns number of bytes read.
-On failure the return value is negative and 'errno' is set. +On failure the return value is negative and errno is set.
[source,c] @@ -90,7 +90,7 @@ This is a wrapper to 'io->Write()'. Writes at most 'size' bytes from an 'IO' stream and stores them into the buffer. Returns number of bytes read.
-On failure the return value is negative and 'errno' is set. +On failure the return value is negative and errno is set.
[source,c] ------------------------------------------------------------------------------- @@ -106,7 +106,7 @@ This is a wrapper to 'io->Close()'. Finalizes reading/writing, closes file descriptors (in case of file IO), frees memory buffers.
-Returns zero on success, non-zero on IO failure and 'errno' is set. +Returns zero on success, non-zero on IO failure and errno is set.
[source,c] @@ -146,7 +146,7 @@ off_t GP_IORewind(GP_IO *io)
Wrapper to 'GP_IOSeek()', rewinds to the start of the IO stream.
-Returns zero on success, non-zero on failure and 'errno' is set. +Returns zero on success, non-zero on failure and errno is set.
[source,c] @@ -160,11 +160,11 @@ GP_IO *GP_IOMem(void *buf, size_t size, void (*free)(void *));
Creates an read-only IO from a memory buffer.
-Returns initialized IO or in case of failure 'NULL' and 'errno' is set. +Returns initialized IO or in case of failure NULL and errno is set.
The 'buf' is pointer to the start of the buffer, the 'size' is size in bytes.
-The 'free()' callback if not 'NULL' is called with the start of the buffer as +The 'free()' callback if not NULL is called with the start of the buffer as an argument on 'IOClose()'.
TIP: See link:example_memory_io.html[memory IO example]. @@ -186,5 +186,5 @@ GP_IO *GP_IOFile(const char *path, enum GP_IOFileMode mode);
Creates an IO stream from a file.
-Returns a pointer to initialized IO stream, or in case of failure 'NULL' and -'errno' is set. +Returns a pointer to initialized IO stream, or in case of failure NULL and +errno is set. diff --git a/doc/loaders_python.txt b/doc/loaders_python.txt index 6ffaaa6a..a73d1f0e 100644 --- a/doc/loaders_python.txt +++ b/doc/loaders_python.txt @@ -35,7 +35,7 @@ fails files signature is used.
|=============================================================================== | May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT' or any other - 'errno' set by 'open(2)', 'read(2)', 'seek(2)'. + errno set by 'open(2)', 'read(2)', 'seek(2)'.
| May raise 'OSError' with errno set to 'ENOSYS' on unsupported or not recognized format or if specific loader was disabled upon compilation. @@ -71,7 +71,7 @@ For the Save() method the file format is derived from the extension.
|=============================================================================== | May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT', 'ENOSPC' - or any other 'errno' set by 'open(2)', 'write(2)', 'seek(2)'. + or any other errno set by 'open(2)', 'write(2)', 'seek(2)'. | May raise 'OSError' with errno set to 'ENOSYS' if pixel type is not supported by the format or if the save method is not implemented (possibly disabled upon compilation). @@ -88,4 +88,4 @@ import gfxprim.loaders as loaders
-------------------------------------------------------------------------------
-Prints all loaders and their capabilites into the 'stdout'. +Prints all loaders and their capabilites into the stdout. diff --git a/doc/pixels.txt b/doc/pixels.txt index 37553c47..ffc3fa1e 100644 --- a/doc/pixels.txt +++ b/doc/pixels.txt @@ -39,12 +39,12 @@ typedef enum GP_PixelType {
-------------------------------------------------------------------------------
-Pixels are described by a pixel type, which is enumeration type. The enum is -defined in the generated 'GP_Pixel.gen.h' header and must contain at least the -members listed above. +Pixels are described by a pixel type, which is an enumeration type.
-The same names as are the enum values are also defined (to themselves) as -macros so that it's possible to use them with 'ifdef'. +The enum is defined in the 'GP_Pixel.gen.h' header link:gen.html[generated] +from a configuration file. + +The header and must contain at least the members listed above.
[source,c] ------------------------------------------------------------------------------- diff --git a/doc/progress_callback.txt b/doc/progress_callback.txt index e12dccf2..9a0e50da 100644 --- a/doc/progress_callback.txt +++ b/doc/progress_callback.txt @@ -33,7 +33,7 @@ periodically and the percentage field is updated.
The return value from callback could abort the execution. If a non-zero value is returned operation is aborted, all memory freed etc., in case of pixmap -loaders 'errno' is set to 'ECANCELED' and in case of pixmap savers the newly +loaders errno is set to 'ECANCELED' and in case of pixmap savers the newly created file is removed too.
The callback, if supported, is the last parameter of a function. diff --git a/doc/text.txt b/doc/text.txt index 3acdd81e..3f3a5e70 100644 --- a/doc/text.txt +++ b/doc/text.txt @@ -42,7 +42,7 @@ GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style, Draws text at the position x and y; the alignment of the text in relation to the point is specified by alignment flags.
-If the 'style' argument is 'NULL', a default style is used. +If the 'style' argument is NULL, a default style is used.
The text size can be computed by following functions:
http://repo.or.cz/w/gfxprim.git/commit/9bf5488c204dba601b1f43ab1a20542207f19...
commit 9bf5488c204dba601b1f43ab1a20542207f194be Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 16 21:17:02 2014 +0100
doc: Update loaders, add TIFF.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf index cd6e25b3..8babf754 100644 --- a/doc/asciidoc.conf +++ b/doc/asciidoc.conf @@ -1,10 +1,14 @@ [specialwords] -emphasizedwords=GFXprim +emphasizedwords=GFXprim errno stdout stdin stderr NULL
[attributes] # use image icons icons
+# Redefine <<>> xref macro +[xref2-inlinemacro] +<a href="#{1}">{2={1}}</a> + [header] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> diff --git a/doc/asciidoc.css b/doc/asciidoc.css index 09829b1f..a863bdb7 100644 --- a/doc/asciidoc.css +++ b/doc/asciidoc.css @@ -1,6 +1,6 @@ /* Default font. */ body { - font-family: Georgia,serif; + font-family: Georgia,Serif; background: #bbb; }
diff --git a/doc/loaders.txt b/doc/loaders.txt index 2a257ca3..7d43aa8a 100644 --- a/doc/loaders.txt +++ b/doc/loaders.txt @@ -3,8 +3,9 @@ Context loaders This part of GFXprim library implements API to load and save images for common image file formats.
-Currently we support 'JPEG', 'PNG', 'BMP', 'TIFF' and 'PNM' images for loading -and saving and 'GIF', 'JPEG2000', 'PCX', 'CBZ', 'PSD' and 'PSP' for loading. +Currently we support <<JPEG>>, <<PNG>>, <<BMP>>, <<TIFF>> and <<PNM>> images for +loading and saving and <<GIF>>, <<JPEG2000>>, <<PCX>>, 'CBZ', <<PSD>> and +<<PSP>> for loading.
Have a look at the link:about.html#Loaders[supported formats] for more detailed information. @@ -16,7 +17,7 @@ Loading functions exists in at least two flavors. One that works with a path to a file and one that reads data from an link:loaders_io.html[IO stream].
All loading functions returns a pointer to newly allocated and loaded image or -upon a failure 'NULL' and 'errno' is set. +upon a failure NULL and errno is set.
The link:context.html[Context] returned by the loaders should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -29,17 +30,19 @@ The signature matching functions takes a 32 bytes long buffer and looks for a valid link:signatures.html[image signature]. If signature is found non-zero is returned.
-In case of a failure 'errno' is set, possible 'errno' values are: - -* anything returned by +open()+, +close()+, +lseek()+, +read()+, +write()+, ... - - 'ENOENT' if file doesn't exist - - 'EACCES' if process doesn't have rights - - etc. - -* 'ENOSYS' if GFXprim wasn't compiled with particular library support -* 'ENOMEM' if returned by +malloc()+ -* 'EIO', 'EINVAL' invalid image data (wrong signature, wrong or too short header or image data) -* 'ECANCELED' action canceled by returning non-zero from within a callback +.Possible errno values +|=============================================================================== +| Any errno returned by underlying 'open()', 'close()', 'lseek()', 'read()', + 'write()', ... +| 'ENOENT' if file doesn't exist +| 'EACCES' if process doesn't have rights to open the file +| 'ENOSYS' if GFXprim wasn't compiled with particular library support +| 'ENOMEM' if returned by 'malloc()' +| 'EIO', 'EINVAL' invalid image data (wrong signature, wrong or too short + header or image data) +| 'ECANCELED' action canceled by returning non-zero from within a + link:progress_callback.html[callback]. +|===============================================================================
You can get more information about the error condition by turning on GFXprim link:environment_variables.html#GP_DEBUG[debug messages]. @@ -90,13 +93,13 @@ Saves a link:context.html[Context] into a file.
The file format is matched accordingly to the file extension.
-If extension is not found non-zero is returned and 'errno' is set to 'EINVAL'. +If extension is not found non-zero is returned and errno is set to 'EINVAL'.
If extension was found but support for saving the image format is not -implemented 'errno' is set to 'ENOSYS' (this may happen in case that GFXprim +implemented errno is set to 'ENOSYS' (this may happen in case that GFXprim wasn't compiled with support for this image type).
-If context pixel type is not supported by the format 'errno' is set to +If context pixel type is not supported by the format errno is set to 'EINVAL'.
[[Register_Loader]] @@ -160,13 +163,13 @@ void GP_LoaderUnregister(GP_Loader *self);
The 'GP_Loader' structure describes an image loader.
-The 'Load', 'Save' and 'Match' functions could be 'NULL' if the particular +The 'Load', 'Save' and 'Match' functions could be NULL if the particular functionality is not implemented.
The 'fmt_name' is a short string that describes the format. For example: 'Netbpm portable pixmap'.
-The extensions is 'NULL'-terminated array of strings that holds all possible +The extensions is NULL-terminated array of strings that holds all possible extensions that are commonly used for this image format.
All internal loaders are all described in list of this structures which is @@ -189,7 +192,7 @@ link:example_loader_registration.html[example]. const GP_Loader *GP_MatchSignature(const void *buf) -------------------------------------------------------------------------------
-Returns pointer to image loader accordingly to image signature or 'NULL' if no +Returns pointer to image loader accordingly to image signature or NULL if no suitable loader was found. The buf pointer must point to a buffer at least 32 bytes long.
@@ -209,9 +212,11 @@ string after the dot) and matches it against known extensions. WARNING: If you attempt to modify the content of the structure the behavior is undefined. Most likely the program will crash.
+[[PNG]] PNG Loader ~~~~~~~~~~ -The 'PNG' image support is implemented by the libpng library. +The 'PNG' image support is implemented by the +link:http://www.libpng.org/%5Blibpng library].
[source,c] ------------------------------------------------------------------------------- @@ -226,7 +231,7 @@ Reads a 'PNG' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'PNG' file signature.
Returns newly allocated context (containing decompressed image) or in case of -failure 'NULL' and 'errno' is set. +failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -243,7 +248,7 @@ GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback); Loads a 'PNG' image from a file.
Returns a pointer to newly allocated loaded image, or in case of failure -'NULL' and 'errno' is set. +NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -259,7 +264,7 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path, -------------------------------------------------------------------------------
Saves a link:context.html[Context] as a 'PNG' image, in case particular pixel -type is not supported non-zero is returned and 'errno' is set to 'ENOSYS'. +type is not supported non-zero is returned and errno is set to 'ENOSYS'.
Supports 'G1', 'G2', 'G4', 'G8', 'G16', and 8-bit 'RGB' and 'RGBA' pixel types. @@ -275,6 +280,7 @@ int GP_MatchPNG(const void *buf);
Matches a 'PNG' link:signatures.html[file signature]. Returns non-zero if found.
+[[JPEG]] JPEG Loader ~~~~~~~~~~~ The 'JPEG' image support is implemented by the jpeg library. @@ -292,7 +298,7 @@ Reads a 'JPEG' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'JPEG' file signature.
Returns newly allocated context (containing decompressed image) or in case of -failure 'NULL' and 'errno' is set. +failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -309,7 +315,7 @@ GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback); Loads a 'JPEG' image from a file.
Returns a pointer to newly allocated loaded image, or in case of failure -'NULL' and 'errno' is set. +NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -340,6 +346,7 @@ int GP_MatchJPG(const void *buf); Matches a 'JPEG' link:signatures.html[file signature]. Returns non-zero if found.
+[[JPEG2000]] JPEG 2000 Loader ~~~~~~~~~~~~~~~~ The 'JPEG 2000' image support is implemented using the openjpeg library. @@ -357,7 +364,7 @@ Reads a 'JPEG2000' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'JPEG2000' file signature.
Returns newly allocated context (containing decompressed image) or in case of -failure 'NULL' and 'errno' is set. +failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -392,10 +399,12 @@ int GP_MatchJP2(const void *buf); Matches a 'JPEG2000' link:signatures.html[file signature]. Returns non-zero if found.
+[[GIF]] GIF Loader ~~~~~~~~~~
-The 'GIF' image support is implemented by the giflib library. +The 'GIF' image support is implemented using the +link:http://sourceforge.net/projects/giflib/%5Bgiflib library].
[source,c] ------------------------------------------------------------------------------- @@ -410,7 +419,7 @@ Reads a 'GIF' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'GIF' file signature.
Returns newly allocated context (containing decompressed image) or in case of -failure 'NULL' and 'errno' is set. +failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -443,6 +452,7 @@ int GP_MatchGIF(const void *buf); Matches a 'GIF' link:signatures.html[file signature]. Returns non-zero if found.
+[[BMP]] BMP Loader ~~~~~~~~~~
@@ -462,7 +472,7 @@ Reads a 'BMP' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'BMP' file signature.
Returns newly allocated context (containing decompressed image) or in case of -failure 'NULL' and 'errno' is set. +failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -507,6 +517,77 @@ int GP_MatchBMP(const void *buf); Matches a 'BMP' link:signatures.html[file signature]. Returns non-zero if found.
+[[TIFF]] +TIFF Loader +~~~~~~~~~~~ + +The 'TIFF' loader support is done using the +link:http://www.remotesensing.org/libtiff/%5Btiff library]. + +Currently only subset of 'tiff' images could be loaded, tiles does not work +yet. + +[source,c] +------------------------------------------------------------------------------- +#include <loaders/GP_TIFF.h> +/* or */ +#include <GP.h> + +GP_Context *GP_ReadTIFF(GP_IO *io, GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +Reads a 'TIFF' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] +is expected to start exactly at the 'TIFF' file signature. + +Returns newly allocated context (containing decompressed image) or in case of +failure NULL and errno is set. + +The resulting link:context.html[Context] should be later freed with +link:context.html#ContextFree[GP_ContextFree()]. + +[source,c] +------------------------------------------------------------------------------- +#include <loaders/GP_TIFF.h> +/* or */ +#include <GP.h> + +GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +Loads a 'TIFF' image from a file. + +The resulting link:context.html[Context] should be later freed with +link:context.html#ContextFree[GP_ContextFree()]. + +[source,c] +------------------------------------------------------------------------------- +#include <loaders/GP_TIFF.h> +/* or */ +#include <GP.h> + +int GP_SaveTIFF(const GP_Context *src, const char *dst_path, + GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +Saves a link:context.html[Context] as a 'TIFF' image. + +Supports 'G1', 'G2', 'G4' and 'G8' grayscale and 8-bit 'RGB' pixel types. + +The image is saved in stripes. + +[source,c] +------------------------------------------------------------------------------- +#include <loaders/GP_TIFF.h> +/* or */ +#include <GP.h> + +int GP_MatchTIFF(const void *buf); +------------------------------------------------------------------------------- + +Matches a 'TIFF' link:signatures.html[file signature]. Returns non-zero if +found. + +[[PSP]] PSP Loader ~~~~~~~~~~
@@ -526,7 +607,7 @@ link:loaders_io.html[IO stream] is expected to start exactly at the 'PSP' file signature.
Returns newly allocated context (containing decompressed image) or in case of -failure 'NULL' and 'errno' is set. +failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -557,6 +638,7 @@ int GP_MatchPSP(const void *buf); Matches a 'PSP' link:signatures.html[file signature]. Returns non-zero if found.
+[[PSD]] PSD Loader ~~~~~~~~~~
@@ -578,7 +660,7 @@ Reads a 'PSD' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'PSD' file signature.
Returns newly allocated context (containing decompressed image) or in case of -failure 'NULL' and 'errno' is set. +failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()]. @@ -597,7 +679,7 @@ Loads a merged image (if present) from a 'PSD' file. Fallbacks to thumbnail if merged image is not present or has unsupported pixel type.
-Returns 'NULL' (TODO ERRNO) if merged image is not present/supported and +Returns NULL (TODO ERRNO) if merged image is not present/supported and thumbnail is not present either.
The resulting link:context.html[Context] should be later freed with @@ -615,6 +697,7 @@ int GP_MatchPSD(const void *buf); Matches a 'PSD' link:signatures.html[file signature]. Returns non-zero if found.
+[[PNM]] PNM Loaders ~~~~~~~~~~~
@@ -734,6 +817,7 @@ The 'PNM' matches all of the formats. i.e. 'PBM', 'PGM' and 'PPM'.
All functions return non-zero if found.
+[[PCX]] PCX Loader ~~~~~~~~~~
@@ -752,7 +836,7 @@ Reads a 'PCX' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'PCX' file signature.
Returns newly allocated context (containing decompressed image) or in case of -failure 'NULL' and 'errno' is set. +failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with link:context.html#ContextFree[GP_ContextFree()].
-----------------------------------------------------------------------
Summary of changes: doc/asciidoc.conf | 6 ++- doc/asciidoc.css | 2 +- doc/backends.txt | 12 ++-- doc/compilation.txt | 56 +++++++++++---- doc/context.txt | 8 +- doc/debug.txt | 4 +- doc/environment_variables.txt | 2 +- doc/event_queue.txt | 4 +- doc/filters.txt | 6 +- doc/filters_dithering.txt | 10 ++-- doc/filters_python.txt | 2 +- doc/filters_resize.txt | 6 +- doc/gamma.txt | 2 +- doc/grabbers.txt | 2 +- doc/input.txt | 2 +- doc/loaders.txt | 154 +++++++++++++++++++++++++++++++--------- doc/loaders_io.txt | 18 +++--- doc/loaders_python.txt | 6 +- doc/pixels.txt | 10 ++-- doc/progress_callback.txt | 2 +- doc/text.txt | 2 +- libs/loaders/GP_ZIP.c | 94 +++++++++++++++++++++---- 22 files changed, 293 insertions(+), 117 deletions(-)
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.