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/c4cb658954c2cd3de44939d096b48eb40438…
commit c4cb658954c2cd3de44939d096b48eb40438d674
Author: Cyril Hrubis <metan(a)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(a)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/623d537b03153f26c9e6cc0d68d7dfa70fb6…
commit 623d537b03153f26c9e6cc0d68d7dfa70fb62058
Author: Cyril Hrubis <metan(a)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(a)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/e78aa462e49f391bc0cf7fc31bde121063e2…
commit e78aa462e49f391bc0cf7fc31bde121063e23f2c
Author: Cyril Hrubis <metan(a)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(a)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/[gcc] and
+ link:http://clang.llvm.org/[clang])
+* link:https://www.gnu.org/software/make/[GNU make]
+* link:https://www.python.org/[Python] (2.6 or newer)
+* link:http://jinja.pocoo.org/docs/[Jinja2]
*Optional Image loaders*
* libjpeg
-* libpng
-* giflib
-* libtiff
-* openjpeg >= 2.0.0
-* zlib (usually installed as libpng dependency)
+* link:http://www.libpng.org/[libpng]
+* link:http://sourceforge.net/projects/giflib/[giflib]
+* link:http://www.remotesensing.org/libtiff/[libtiff]
+* link:http://code.google.com/p/openjpeg/[openjpeg] >= 2.0.0
+* link:http://www.zlib.net/[zlib] (usually installed as libpng dependency)
*Optinal Text rendering*
-* FreeType
+* link:http://www.freetype.org/[FreeType]
*Optional Backends*
* X11
-* AA-lib
-* SDL-1.2 (not recomended, known to be slow and buggy)
+* link:http://aa-project.sourceforge.net/aalib/[AA-lib]
+* link:http://www.libsdl.org/[SDL] 1.2
+ (not recomended, known to be slow and buggy)
*Python Bindings*
-* Swig
+* link:http://www.swig.org/[Swig]
* 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/[OpenSUSE].
@@ -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[Debian]
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[build 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/556a69a3e1bb48998da72d810b8daec1af99…
commit 556a69a3e1bb48998da72d810b8daec1af997f49
Author: Cyril Hrubis <metan(a)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(a)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/9bf5488c204dba601b1f43ab1a20542207f1…
commit 9bf5488c204dba601b1f43ab1a20542207f194be
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 16 21:17:02 2014 +0100
doc: Update loaders, add TIFF.
Signed-off-by: Cyril Hrubis <metan(a)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/[libpng 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/[giflib 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/[tiff 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(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 05ec5cc78e822d2d4d45b54280997526d5e1bd64 (commit)
from c2fb0ec9b8d440b7128d76344907b20ad292885e (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/05ec5cc78e822d2d4d45b54280997526d5e1…
commit 05ec5cc78e822d2d4d45b54280997526d5e1bd64
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Mar 14 00:13:22 2014 +0100
doc: loaders: Fixed + add signatures.txt
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/Makefile b/doc/Makefile
index ac8868c2..2b56050d 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -5,7 +5,7 @@ SOURCES=index.html about.txt context.txt loaders.txt filters.txt get_put_pixel.txt blits.txt progress_callback.txt text.txt event_queue.txt compilation.txt filters_resize.txt filters_dithering.txt filters_python.txt spiv.txt core_common.txt - convert.txt news_1_0_0-rc1.txt loaders_io.txt
+ convert.txt news_1_0_0-rc1.txt loaders_io.txt signatures.txt
SOURCES+=core_python.txt gfx_python.txt loaders_python.txt backends_python.txt
diff --git a/doc/context.txt b/doc/context.txt
index 0d42abde..b8213ffe 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -210,6 +210,7 @@ flags are set to zero.
The 'free_pixels' flag for the resulting context is set.
+[[ContextFree]]
[source,c]
-------------------------------------------------------------------------------
#include <core/GP_Context.h>
diff --git a/doc/loaders.txt b/doc/loaders.txt
index af588cb9..2a257ca3 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -1,28 +1,33 @@
Context loaders
---------------
-This part of GFXprim library aims to create API to load and save images
-from/to common image file formats.
+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' and 'PSP' 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].
+Have a look at the link:about.html#Loaders[supported formats] for more
+detailed information.
Image Loaders and Savers
~~~~~~~~~~~~~~~~~~~~~~~~
-All loading functions exists in at least two flavors. One that works with a
-path to a file and one that reads from an link:loaders_io.html[IO stream].
+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.
+All loading functions returns a pointer to newly allocated and loaded image or
+upon a failure 'NULL' and 'errno' is set.
-All saving functions returns zero on success and non-zero on failure. If
-image saving is aborted by a callback, the opened file is closed and removed
-from a file-system before the call returns.
+The link:context.html[Context] returned by the loaders should be later freed
+with link:context.html#ContextFree[GP_ContextFree()].
-The signature matching functions takes a 32 bytes long buffer and looks for a
-valid image signature. If signature is found non-zero is returned.
+All saving functions returns zero on success and non-zero on failure. If image
+saving is aborted by a callback, the opened file is closed and removed from a
+file-system before the call returns.
+
+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:
@@ -39,6 +44,9 @@ In case of a failure 'errno' is set, possible 'errno' values are:
You can get more information about the error condition by turning on GFXprim
link:environment_variables.html#GP_DEBUG[debug messages].
+General interface
+^^^^^^^^^^^^^^^^^
+
[[Load_Image]]
[source,c]
-------------------------------------------------------------------------------
@@ -51,19 +59,21 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback);
Loads an image from a file.
-The image format is first guessed by the file extension. If loader for the
-file extension is found it's called and if it succeeds the image data is
-returned.
+The image format is first guessed by the file extension. If loader is found
+and if it succeeds to load the image the newly loaded image is returned.
If file extension based guess fails either because the extension wasn't
-matched or if the loader for the extension failed; the signature based method
-is used. The loader loads several bytes (currently 32) from the file and
-calls signature matching functions for each format that implements signature
-matching. If image signature is found image loader it is called and the result
-is returned.
+matched or if the loader for the extension failed; the
+link:signatures.html[file signature] based method is used. The loader loads
+several bytes (currently 32) from the file and calls signature matching
+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'.
-If file extension disagrees with file signature on the file format a warning
-is printed into the 'stderr'.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
[[Save_Image]]
[source,c]
@@ -76,7 +86,7 @@ int GP_SaveImage(GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves a context into a file.
+Saves a link:context.html[Context] into a file.
The file format is matched accordingly to the file extension.
@@ -90,8 +100,8 @@ If context pixel type is not supported by the format 'errno' is set to
'EINVAL'.
[[Register_Loader]]
-Advanced Loaders usage
-^^^^^^^^^^^^^^^^^^^^^^
+Advanced Interface
+^^^^^^^^^^^^^^^^^^
[source,c]
-------------------------------------------------------------------------------
@@ -218,6 +228,9 @@ 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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PNG.h>
@@ -232,6 +245,9 @@ 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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PNG.h>
@@ -242,8 +258,8 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves a 'Context' into a 'PNG' image, in case particular pixel type is not
-supported non-zero is returned and 'errno' is set to 'ENOSYS'.
+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'.
Supports 'G1', 'G2', 'G4', 'G8', 'G16', and 8-bit 'RGB' and 'RGBA' pixel
types.
@@ -257,7 +273,7 @@ types.
int GP_MatchPNG(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'PNG' file signature. Returns non-zero if found.
+Matches a 'PNG' link:signatures.html[file signature]. Returns non-zero if found.
JPEG Loader
~~~~~~~~~~~
@@ -278,6 +294,9 @@ 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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_JPG.h>
@@ -287,11 +306,14 @@ failure 'NULL' and 'errno' is set.
GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads an 'JPEG' image from a file.
+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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_JPG.h>
@@ -302,9 +324,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Writes a 'Context' into a 'JPEG' image. If aborted by a callback, the opened
-file is closed and removed before the call returns non-zero and 'errno' is set
-to 'ECANCELED'.
+Saves a link:context.html[Context] as a 'JPEG' image.
The 'JPEG' format could store either 'G8' or 8-bit 'RGB' pixel-types.
@@ -317,7 +337,8 @@ The 'JPEG' format could store either 'G8' or 8-bit 'RGB' pixel-types.
int GP_MatchJPG(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'JPEG' file signature. Returns non-zero if found.
+Matches a 'JPEG' link:signatures.html[file signature]. Returns non-zero if
+found.
JPEG 2000 Loader
~~~~~~~~~~~~~~~~
@@ -338,6 +359,9 @@ 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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
NOTE: Due to limitations of the openjpeg library progress callback does not work.
[source,c]
@@ -349,7 +373,10 @@ NOTE: Due to limitations of the openjpeg library progress callback does not work
GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads 'JPEG2000' image from a file.
+Loads a 'JPEG2000' image from a file.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
NOTE: Due to limitations of the openjpeg library progress callback does not work.
@@ -362,7 +389,8 @@ NOTE: Due to limitations of the openjpeg library progress callback does not work
int GP_MatchJP2(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'JPEG2000' file signature. Returns non-zero if found.
+Matches a 'JPEG2000' link:signatures.html[file signature]. Returns non-zero if
+found.
GIF Loader
~~~~~~~~~~
@@ -384,6 +412,9 @@ 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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
NOTE: Currently this function loads only first image from the 'GIF' container.
[source,c]
@@ -395,7 +426,10 @@ NOTE: Currently this function loads only first image from the 'GIF' container.
GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads 'GIF' image from a file.
+Loads a 'GIF' image from a file.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
[source,c]
-------------------------------------------------------------------------------
@@ -406,7 +440,8 @@ Loads 'GIF' image from a file.
int GP_MatchGIF(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'GIF' file signature. Returns non-zero if found.
+Matches a 'GIF' link:signatures.html[file signature]. Returns non-zero if
+found.
BMP Loader
~~~~~~~~~~
@@ -429,6 +464,9 @@ 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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_BMP.h>
@@ -438,7 +476,10 @@ failure 'NULL' and 'errno' is set.
GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads 'BMP' image from a file.
+Loads a 'BMP' image from a file.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
[source,c]
-------------------------------------------------------------------------------
@@ -450,9 +491,9 @@ int GP_SaveBMP(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Writes a 'Context' into a 'BMP' file.
+Saves a link:context.html[Context] as a 'BMP' image.
-Currently only 8-bit 'RGB' formats are supported.
+Currently only 8-bit 'RGB' pixel types are supported.
[source,c]
-------------------------------------------------------------------------------
@@ -463,7 +504,8 @@ Currently only 8-bit 'RGB' formats are supported.
int GP_MatchBMP(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'BMP' file signature. Returns non-zero if found.
+Matches a 'BMP' link:signatures.html[file signature]. Returns non-zero if
+found.
PSP Loader
~~~~~~~~~~
@@ -479,12 +521,16 @@ The 'PSP' loader can load a composite image from a Paint Shop Pro Image Files.
GP_Context *GP_ReadPSP(GP_IO *io, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Reads a 'PSP' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
-is expected to start exactly at the 'PSP' file signature.
+Reads a 'PSP' composite image from readable 'GP_IO'. The
+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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PSP.h>
@@ -496,6 +542,9 @@ GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback);
Loads a composite image from a 'PSP' file.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PSP.h>
@@ -505,7 +554,8 @@ Loads a composite image from a 'PSP' file.
int GP_MatchPSP(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'PSP' file signature. Returns non-zero if found.
+Matches a 'PSP' link:signatures.html[file signature]. Returns non-zero if
+found.
PSD Loader
~~~~~~~~~~
@@ -524,12 +574,15 @@ RGB).
GP_Context *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Reads a 'PSP' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
+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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PSD.h>
@@ -547,6 +600,9 @@ type.
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
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PSD.h>
@@ -556,7 +612,8 @@ thumbnail is not present either.
int GP_MatchPSD(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'PSD' file signature. Returns non-zero if found.
+Matches a 'PSD' link:signatures.html[file signature]. Returns non-zero if
+found.
PNM Loaders
~~~~~~~~~~~
@@ -567,6 +624,28 @@ PNM Loaders
/* or */
#include <GP.h>
+GP_Context *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback);
+
+GP_Context *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback);
+
+GP_Context *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback);
+
+GP_Context *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Reads a ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM' image from readable
+'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at
+the file signature.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PNM.h>
+/* or */
+#include <GP.h>
+
GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback);
GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback);
@@ -578,7 +657,10 @@ GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback);
Loads either ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM'.
-The 'PNM' can load all of them i.e. 'PBM', 'PGM' and 'PPM'.
+The 'PNM' loader can load all of them i.e. 'PBM', 'PGM' and 'PPM'.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
[source,c]
-------------------------------------------------------------------------------
@@ -590,7 +672,7 @@ GP_Context *GP_SavePBM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves 'G1' (1 bit grayscale) image into ASCII 'PBM'.
+Saves 'G1' (1 bit grayscale) image as ASCII 'PBM'.
[source,c]
-------------------------------------------------------------------------------
@@ -602,7 +684,7 @@ GP_Context *GP_SavePGM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4 and 8 bit grayscale) image into ASCII
+Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4 and 8 bit grayscale) image as ASCII
'PGM'.
[source,c]
@@ -615,7 +697,7 @@ GP_Context *GP_SavePPM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves 'RGB888' (24 bit RGB) image into ASCII 'PPM'.
+Saves 'RGB888' (24 bit RGB) image as ASCII 'PPM'.
[source,c]
-------------------------------------------------------------------------------
@@ -628,7 +710,7 @@ GP_Context *GP_SavePNM(const GP_Context *src, const char *dst_path,
-------------------------------------------------------------------------------
Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4, 8 bit grayscale) or 'RGB888' (24 bit
-RGB) image into ASCII 'PNM'.
+RGB) image as ASCII 'PNM'.
[source,c]
-------------------------------------------------------------------------------
@@ -645,8 +727,8 @@ int GP_MatchPPM(const void *buf);
int GP_MatchPNM(const void *buf);
-------------------------------------------------------------------------------
-Matches either ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM' file
-signatures.
+Matches either ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM'
+link:signatures.html[file signatures].
The 'PNM' matches all of the formats. i.e. 'PBM', 'PGM' and 'PPM'.
@@ -672,6 +754,9 @@ 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.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PCX.h>
@@ -683,6 +768,9 @@ GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback);
Loads a 'PCX' 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_PCX.h>
@@ -692,4 +780,5 @@ Loads a 'PCX' image from a file.
int GP_MatchPCX(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'PCX' file signature. Returns non-zero if found.
+Matches a 'PCX' link:signatures.html[file signature]. Returns non-zero if
+found.
diff --git a/doc/signatures.txt b/doc/signatures.txt
new file mode 100644
index 00000000..fce2bf93
--- /dev/null
+++ b/doc/signatures.txt
@@ -0,0 +1,36 @@
+File signatures
+---------------
+
+File signature is a short well defined sequence of bytes usually situated at
+the beginning of the file.
+
+.Table of image file signatures used by GFXprim loaders
+[options="autowidth,header"]
+|=============================================================================
+| Extension | Format Name | Signature | Signature in Hex
+| *JPEG* | | | +0xff 0xd8 0xff+
+| *PNG* | Portable Network Graphics | +211PNGrn032n+ |
+ +89 50 4e 47 0d 0a 1a 0a+
+| *GIF* | Graphics Interchange Format | +GIF87a or GIF89a+ |
+| *BMP* | | +BM+ | +42 4d+
+| *TIFF* | Tagged Image File Format | +II*0 or MM0*+ | +49 49 2a 00 or
+ 4d 4d 2a 00+
+| *PSP* | Paint Shop Pro Image |
+ +Paint Shop Pro Image Filenx1a00000000+ |
+| *PSD* | Adobe Photoshop Image | +8BPS0x01+ |
+| *PBM* | Netpbm portable bitmap | +P1 or P4+ |
+| *PGM* | Netpbm portable graymap | +P2 or P5+ |
+| *PPM* | Netpbm portable pixmap | +P3 or P6+ |
+| *PNM* | Netpbm portable anymap | +P1, P2, P3, P4, P5, P6+ |
+| *JP2* | JPEG 2000 |
++000x0cjPx20x20x0dx0ax87x0a+ | +00 00 00 0c 6a 50 20 20 0d 0a 87 0a+
+| *PCX* | ZSoft PCX || +0a [01-05] 0x01 {01, 02, 04, 08}+
+| *CBZ* | Comic Book Archive (ZIP) | +PK0304+ |
+|=============================================================================
+
+
+Explanation
+~~~~~~~~~~~
+ * Signature strings are written in C string syntax
+ * The [A-B] denotes any number from interval
+ * The {A, B, C} denotes any number from the set
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile | 2 +-
doc/context.txt | 1 +
doc/loaders.txt | 199 +++++++++++++++++++++++++++++++++++++--------------
doc/signatures.txt | 36 ++++++++++
4 files changed, 182 insertions(+), 56 deletions(-)
create mode 100644 doc/signatures.txt
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 972b83d7f74f4c22839536d0604183c717f545dc (commit)
via 71dc80d8bbbdc5af75aed1896288e2d7a34cdead (commit)
from 42571d6c7b8ffe8318c1ecfa32dbba3fc3c9c28b (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/972b83d7f74f4c22839536d0604183c717f5…
commit 972b83d7f74f4c22839536d0604183c717f545dc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 2 21:29:00 2014 +0100
PCX: Implement PCX RLE I/O stream.
The loaders now internally uses RLE I/O stream.
TODO: Check errors from GP_IORead() in inner loops
More tests
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/loaders/GP_PCX.h b/include/loaders/GP_PCX.h
index 0d7d6e22..f5ce05c1 100644
--- a/include/loaders/GP_PCX.h
+++ b/include/loaders/GP_PCX.h
@@ -33,7 +33,6 @@
#include "core/GP_ProgressCallback.h"
#include "loaders/GP_IO.h"
-
/*
* Reads a PCX from an IO stream.
*
diff --git a/libs/loaders/GP_PCX.c b/libs/loaders/GP_PCX.c
index 698f82eb..61806583 100644
--- a/libs/loaders/GP_PCX.c
+++ b/libs/loaders/GP_PCX.c
@@ -37,6 +37,132 @@
#include "GP_PCX.h"
+/*
+ * PCX RLE I/O Stream
+ */
+struct rle {
+ /* RLE internal state */
+ int cnt;
+ int val;
+
+ /* Read counter */
+ off_t pos;
+
+ /* Source I/O stream */
+ GP_IO *io;
+
+ /* Read buffer */
+ ssize_t buf_fill;
+ ssize_t buf_pos;
+ uint8_t buf[128];
+};
+
+static int rle_getc(struct rle *rle)
+{
+ if (rle->buf_pos < rle->buf_fill)
+ return rle->buf[rle->buf_pos++];
+
+ rle->buf_fill = GP_IORead(rle->io, rle->buf, sizeof(rle->buf));
+
+ if (rle->buf_fill <= 0)
+ return -1;
+
+ rle->buf_pos = 1;
+ return rle->buf[0];
+}
+
+/*
+ * RLE I/O stream
+ *
+ * - reads exactly size bytes unless read from underlying I/O has failed
+ *
+ * - the size is expected to be multiple of bytes_per_line, the specification
+ * forbids for RLE to span across pixel lines, but there are images that does
+ * so. This code only prints a warning in this case.
+ */
+static ssize_t rle_read(GP_IO *self, void *buf, size_t size)
+{
+ struct rle *priv = GP_IO_PRIV(self);
+ unsigned int read = 0;
+ uint8_t *bbuf = buf;
+ int b;
+
+ for (;;) {
+ while (priv->cnt > 0 && read < size) {
+ bbuf[read++] = priv->val;
+ priv->cnt--;
+ }
+
+ if (read >= size) {
+ priv->pos += read;
+ if (priv->cnt)
+ GP_WARN("Nonzero repeat count (%u) %02x at %zi",
+ priv->cnt, priv->val, priv->pos);
+ //priv->cnt = 0;
+ return read;
+ }
+
+ b = rle_getc(priv);
+
+ if (b < 0)
+ return priv->buf_fill;
+
+ if ((b & 0xc0) == 0xc0) {
+ priv->cnt = b & 0x3f;
+ priv->val = rle_getc(priv);
+ if (priv->val < 0)
+ return priv->buf_fill;
+ } else {
+ priv->cnt = 1;
+ priv->val = b;
+ }
+ }
+}
+
+/*
+ * Only seeks forward to skip padding also works for GP_IOTell().
+ */
+static off_t rle_seek(GP_IO *self, off_t off, enum GP_IOWhence whence)
+{
+ uint8_t b;
+ struct rle *priv = GP_IO_PRIV(self);
+
+ if (whence != GP_IO_SEEK_CUR || off < 0)
+ return EINVAL;
+
+ while (off--)
+ rle_read(self, &b, 1);
+
+ return priv->pos;
+}
+
+static int rle_close(GP_IO *self)
+{
+ free(self);
+ return 0;
+}
+
+GP_IO *rle(GP_IO *io)
+{
+ GP_IO *rle = malloc(sizeof(GP_IO) + sizeof(struct rle));
+
+ if (!rle)
+ return NULL;
+
+ struct rle *priv = GP_IO_PRIV(rle);
+
+ priv->cnt = 0;
+ priv->buf_fill = 0;
+ priv->io = io;
+
+ rle->Read = rle_read;
+ rle->Write = NULL;
+ rle->Seek = rle_seek;
+ rle->Close = rle_close;
+
+ return rle;
+}
+
/* Creator ZSoft: 0x0a
* Version: 0x00, 0x02, 0x03, 0x04, 0x05
* RLE: 0x01
@@ -88,69 +214,6 @@ struct pcx_header {
uint8_t palette[48];
};
-static int get_byte(GP_IO *io)
-{
- uint8_t buf;
-
- if (GP_IORead(io, &buf, 1) != 1)
- return -1;
-
- return buf;
-}
-
-static int readline(GP_IO *io, uint8_t *buf, unsigned int size, unsigned int padd)
-{
- int b, val = 0, cnt = 0;
- unsigned int read = 0;
-
- for (;;) {
- while (cnt > 0 && read < size) {
- buf[read++] = val;
- cnt--;
- }
-
- if (read >= size) {
- goto end;
- }
-
- b = get_byte(io);
-
- if (b == -1) {
- GP_WARN("End of file reached unexpectedly");
- return 0;
- }
-
- if ((b & 0xc0) == 0xc0) {
- cnt = b & 0x3f;
- val = get_byte(io);
- } else {
- cnt = 1;
- val = b;
- }
- }
-
-end:
- /*
- * Data may be padded, read the excess bytes
- */
- while (padd--) {
- if (cnt) {
- cnt--;
- } else {
- b = get_byte(io);
- if ((b & 0xc0) == 0xc0) {
- cnt = b & 0x3f;
- get_byte(io);
- }
- }
- }
-
- if (cnt)
- GP_WARN("Nonzero repeat count at the line end (%u)", cnt);
-
- return 0;
-}
-
#include "core/GP_BitSwap.h"
static int read_g1(GP_IO *io, struct pcx_header *header,
@@ -164,20 +227,26 @@ static int read_g1(GP_IO *io, struct pcx_header *header,
return EINVAL;
}
+ GP_IO *rle_io = rle(io);
+ if (!rle_io)
+ return errno;
+
for (y = 0; y < res->h; y++) {
uint8_t *addr = GP_PIXEL_ADDR(res, 0, y);
-
- readline(io, addr, res->bytes_per_row, padd);
+ GP_IORead(rle_io, addr, res->bytes_per_row);
+ GP_IOSeek(rle_io, GP_IO_SEEK_CUR, padd);
//TODO: FIX Endians
GP_BitSwapRow_B1(addr, res->bytes_per_row);
if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) {
GP_DEBUG(1, "Operation aborted");
+ GP_IOClose(rle_io);
return ECANCELED;
}
}
+ GP_IOClose(rle_io);
return 0;
}
@@ -188,8 +257,14 @@ static int read_rgb888(GP_IO *io, struct pcx_header *header,
unsigned int bpr = header->bytes_per_line;
uint8_t b[3 * bpr];
+ GP_IO *rle_io = rle(io);
+ if (!rle_io)
+ return errno;
+
for (y = 0; y < res->h; y++) {
- readline(io, b, sizeof(b), 0);
+ //readline(io, b, sizeof(b), 0);
+
+ GP_IORead(rle_io, b, sizeof(b));
for (x = 0; x < res->w; x++) {
GP_Pixel pix = GP_Pixel_CREATE_RGB888(b[x],
@@ -200,10 +275,12 @@ static int read_rgb888(GP_IO *io, struct pcx_header *header,
if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) {
GP_DEBUG(1, "Operation aborted");
+ GP_IOClose(rle_io);
return ECANCELED;
}
}
+ GP_IOClose(rle_io);
return 0;
}
@@ -236,8 +313,12 @@ static int read_16_palette(GP_IO *io, struct pcx_header *header,
return EINVAL;
}
+ GP_IO *rle_io = rle(io);
+ if (!rle_io)
+ return errno;
+
for (y = 0; y < res->h; y++) {
- readline(io, b, sizeof(b), 0);
+ GP_IORead(rle_io, b, sizeof(b));
i = 0;
@@ -252,55 +333,67 @@ static int read_16_palette(GP_IO *io, struct pcx_header *header,
if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) {
GP_DEBUG(1, "Operation aborted");
+ GP_IOClose(rle_io);
return ECANCELED;
}
}
+ GP_IOClose(rle_io);
return 0;
}
+#define PALETTE_SIZE (3 * 256 + 1)
+
static int read_256_palette(GP_IO *io, struct pcx_header *header,
GP_Context *res, GP_ProgressCallback *callback)
{
uint32_t x, y;
unsigned int i;
+ uint8_t buf[GP_MAX(PALETTE_SIZE, header->bytes_per_line)];
GP_Pixel palette[256];
- uint8_t b[header->bytes_per_line];
if (GP_IOSeek(io, -769, GP_IO_SEEK_END) == (off_t)-1) {
GP_DEBUG(1, "Failed to seek to palette: %s", strerror(errno));
return EIO;
}
- if (get_byte(io) != 0x0c) {
- GP_DEBUG(1, "Wrong palette marker");
+ if (GP_IOFill(io, buf, PALETTE_SIZE)) {
+ GP_DEBUG(1, "Failed to read palette: %s", strerror(errno));
return EIO;
}
- for (i = 0; i < 256; i++) {
- palette[i] = get_byte(io) << 16;
- palette[i] |= get_byte(io) << 8;
- palette[i] |= get_byte(io);
+ if (buf[0] != 0x0c) {
+ GP_DEBUG(1, "Wrong palette marker");
+ return EIO;
}
+ for (i = 0; i < 256; i++)
+ palette[i] = (buf[3*i+1]<<16) | (buf[3*i+2])<<8 | buf[3*i+3];
+
if (GP_IOSeek(io, 128, GP_IO_SEEK_SET) == (off_t)-1) {
GP_DEBUG(1, "Failed to seek to image data: %s",
strerror(errno));
return EIO;
}
+ GP_IO *rle_io = rle(io);
+ if (!rle_io)
+ return errno;
+
for (y = 0; y < res->h; y++) {
- readline(io, b, sizeof(b), 0);
+ GP_IORead(rle_io, buf, header->bytes_per_line);
for (x = 0; x < res->w; x++)
- GP_PutPixel_Raw_24BPP(res, x, y, palette[b[x]]);
+ GP_PutPixel_Raw_24BPP(res, x, y, palette[buf[x]]);
if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) {
GP_DEBUG(1, "Operation aborted");
+ GP_IOClose(rle_io);
return ECANCELED;
}
}
+ GP_IOClose(rle_io);
return 0;
}
http://repo.or.cz/w/gfxprim.git/commit/71dc80d8bbbdc5af75aed1896288e2d7a34c…
commit 71dc80d8bbbdc5af75aed1896288e2d7a34cdead
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 2 18:45:02 2014 +0100
doc: loaders: Add PSD + cleanup.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.1 b/demos/spiv/spiv.1
index fb23f1f5..bca63dd6 100644
--- a/demos/spiv/spiv.1
+++ b/demos/spiv/spiv.1
@@ -11,9 +11,9 @@ is a fast, lightweight and minimalistic image viewer build on the
top of the GFXprim library.
.PP
Spiv supports wide range of image formats, currently supported are
-JPEG, PNG, GIF, BMP, TIFF, PSP, PNM, PCX, JPEG2000 and CBZ (as well
-general ZIP archives with images), and more will come in the
-near future.
+JPEG, PNG, GIF, BMP, TIFF, PSP, PSD, PNM, PCX, JPEG2000 and CBZ
+(as well general ZIP archives with images), and more will come in
+the near future.
.PP
Spiv supports variety of video backends (via GFXprim backends)
currently these are X11, Linux Framebuffer, SDL and AAlib. Spiv also
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index 186b1c53..cecd1ecb 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -164,9 +164,9 @@ const char *man_head =
"top of the GFXprim library.n"
".PPn"
"Spiv supports wide range of image formats, currently supported aren"
- "JPEG, PNG, GIF, BMP, TIFF, PSP, PNM, PCX, JPEG2000 and CBZ (as welln"
- "general ZIP archives with images), and more will come in then"
- "near future.n"
+ "JPEG, PNG, GIF, BMP, TIFF, PSP, PSD, PNM, PCX, JPEG2000 and CBZn"
+ "(as well general ZIP archives with images), and more will come inn"
+ "the near future.n"
".PPn"
"Spiv supports variety of video backends (via GFXprim backends)n"
"currently these are X11, Linux Framebuffer, SDL and AAlib. Spiv alson"
diff --git a/doc/about.txt b/doc/about.txt
index 018d71f9..f632eaaf 100644
--- a/doc/about.txt
+++ b/doc/about.txt
@@ -99,6 +99,11 @@ images into various standard formats (PNG, JPEG, GIF, TIFF, BMP, PNM, etc...).
[green]#Composite image only for newer formats than 3.0# |
[black]*No*
+| PSD |
+ Adobe Photoshop Image |
+ [green]#Thumbnail or Merged image (16 bit RGB and CMYK not supported yet)#|
+ [black]*No*
+
| PBM PGM PPM PNM |
Netpbm portable bitmap |
[green]#All but < 8bit binary grayscale# |
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 1734718a..af588cb9 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -507,6 +507,57 @@ int GP_MatchPSP(const void *buf);
Matches a 'PSP' file signature. Returns non-zero if found.
+PSD Loader
+~~~~~~~~~~
+
+The 'PSD' loader can load a merged image (if present) or a thumbnail from an
+Adobe Photoshop Image. Currently 16bit RGB and 16bit CMYK is not supported and
+the loader will fallback to the thumbnail in this case (which is always 8bit
+RGB).
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PSD.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Reads a 'PSP' 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.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PSD.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+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
+thumbnail is not present either.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PSD.h>
+/* or */
+#include <GP.h>
+
+int GP_MatchPSD(const void *buf);
+-------------------------------------------------------------------------------
+
+Matches a 'PSD' file signature. Returns non-zero if found.
+
PNM Loaders
~~~~~~~~~~~
diff --git a/doc/loaders_python.txt b/doc/loaders_python.txt
index ae2207e7..6ffaaa6a 100644
--- a/doc/loaders_python.txt
+++ b/doc/loaders_python.txt
@@ -23,6 +23,7 @@ import gfxprim.loaders as loaders
img = loaders.LoadPPM(path, callback=None)
img = loaders.LoadPCX(path, callback=None)
img = loaders.LoadPSP(path, callback=None)
+ img = loaders.LoadPSD(path, callback=None)
img = loaders.LoadTIFF(path, callback=None)
-------------------------------------------------------------------------------
@@ -32,17 +33,20 @@ First one is general purpose loader function that automatically detects the
file format. The format is detected from file extension first and if this
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)'.
+|===============================================================================
+| May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT' or any other
+ 'errno' set by 'open(2)', 'read(2)', 'seek(2)'.
-May raise 'OSError' with errno set to 'ENOSYS' on unsupported or not recognized
-format.
+| May raise 'OSError' with errno set to 'ENOSYS' on unsupported or not recognized
+ format or if specific loader was disabled upon compilation.
-May raise 'OSError' with errno set to 'EIO' when file is damaged.
+| May raise 'OSError' with errno set to 'EIO' or 'EINVAL' when file is damaged.
-May raise 'OSError' with errno set to 'ECANCELED' when action was aborted from
-callback. See progress callback
-link:core_python.html#Progress_Callback[documentation] for more.
+| May raise 'OSError' with errno set to 'ECANCELED' when action was aborted from
+ callback. See link:core_python.html#Progress_Callback[progress callback] for
+ more.
+
+|===============================================================================
[source,python]
@@ -65,16 +69,16 @@ Save image to a file.
For the Save() method the file format is derived from the extension.
-May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT' or any other
-'errno' set by 'open(2)', 'write(2)', 'seek(2)'.
-
-May raise 'OSError' with errno set to 'ENOSYS' on unsupported pixel type for
-a given format.
-
-May raise 'OSError' with errno set to 'EIO' when filesystem is full.
-
-May raise 'OSError' with errno set to 'ECANCELED' when action was interrupted
-by callback.
+|===============================================================================
+| May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT', 'ENOSPC'
+ 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).
+| May raise 'OSError' with errno set to 'ECANCELED' when action was interrupted
+ by callback. See link:core_python.html#Progress_Callback[progress callback]
+ for more.
+|===============================================================================
[source,python]
-------------------------------------------------------------------------------
diff --git a/doc/spiv.txt b/doc/spiv.txt
index 0fd031b1..4f678b82 100644
--- a/doc/spiv.txt
+++ b/doc/spiv.txt
@@ -6,8 +6,8 @@ Spiv is a fast, lightweight and minimalistic image viewer build on the top of
the GFXprim library.
Spiv supports wide range of image formats, currently supported are JPEG, PNG,
-GIF, BMP, TIFF, PSP, PNM, PCX, JPEG2000 and CBZ (as well general ZIP archives
-with images), and more will come in the near future.
+GIF, BMP, TIFF, PSP, PSD, PNM, PCX, JPEG2000 and CBZ (as well general ZIP
+archives with images), and more will come in the near future.
Spiv implements image caches with LRU (last recently used) algorithm which
speeds up subsequent image operations (rotations, going back and forth).
diff --git a/include/loaders/GP_PSD.h b/include/loaders/GP_PSD.h
index 8ab5b619..d8cd2213 100644
--- a/include/loaders/GP_PSD.h
+++ b/include/loaders/GP_PSD.h
@@ -22,7 +22,7 @@
/*
- PSD thumbnail image loader.
+ PSD image loader.
*/
@@ -34,7 +34,11 @@
#include "loaders/GP_IO.h"
/*
- * Reads a PSD thumbnail from an IO stream.
+ * Reads a PSD from an IO stream.
+ *
+ * The loaders tries to read merged image (if present) and fallback to
+ * thumbnail. It may return NULL with errno untouched if neither merged image
+ * nor thumbnail was present (which seem to be really uncommon).
*
* Returns newly allocated context cotaining the loaded image or in case of
* failure NULL and errno is set.
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.1 | 6 +-
demos/spiv/spiv_help.c | 6 +-
doc/about.txt | 5 +
doc/loaders.txt | 51 ++++++++++
doc/loaders_python.txt | 40 ++++----
doc/spiv.txt | 4 +-
include/loaders/GP_PCX.h | 1 -
include/loaders/GP_PSD.h | 8 +-
libs/loaders/GP_PCX.c | 245 +++++++++++++++++++++++++++++++--------------
9 files changed, 261 insertions(+), 105 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")