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
discards f68afbebe846cbdba887cd1f19a26de2f130a182 (commit)
via 6f8f6b43ebf8f58d705e3c6e9499d279f20e7b0b (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (f68afbebe846cbdba887cd1f19a26de2f130a182)
N -- N -- N (6f8f6b43ebf8f58d705e3c6e9499d279f20e7b0b)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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/6f8f6b43ebf8f58d705e3c6e9499d279f20e…
commit 6f8f6b43ebf8f58d705e3c6e9499d279f20e7b0b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 5 14:40:43 2012 +0200
doc: A few fixes.
diff --git a/doc/basic_types.txt b/doc/basic_types.txt
index b3328e9..2a14c95 100644
--- a/doc/basic_types.txt
+++ b/doc/basic_types.txt
@@ -111,7 +111,8 @@ If non 'NULL' progress callback structure is passed to a function, the
callback function is periodically called and the percentage is updated.
The return value from callback could abort the function execution. If non zero
-value is returned the filter is aborted, all memory freed etc.
+value is returned the filter is aborted, all memory freed etc. and in case of
+bitmap loaders 'errno' is set to 'ECANCELED'.
The callback, if supported, is the last parameter of a function.
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 409c940..7d5d0c5 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -4,15 +4,15 @@ This part of gfxprim library aims to create API to load/save images from/to
common image file formats.
All loading functions returns a pointer to allocated and loaded image or upon
-a failure NULL is returned and errno is set.
+a failure 'NULL' is returned and 'errno' is set.
The possible errno values are:
* anything returned by fopen(), fclose(), fseek(), ...
-* ENOSYS if library wasn't compiled with particual library support
-* ENOMEM as returned by malloc()
-* EIO/EILSEQ invalid image data
-* ECANCELED loading canceled from callback
+* 'ENOSYS' if library wasn't compiled with particual library support
+* 'ENOMEM' as returned by malloc()
+* 'EIO'/'EILSEQ' invalid image data
+* 'ECANCELED' loading canceled from callback
Common Loader
~~~~~~~~~~~~~
@@ -49,7 +49,7 @@ Opens file and checks for 'PNG' signature. Returns zero on success (file
could be opened, signature matches), the opened file is returned and the file
possition points right after the end of the 'PNG' signature.
-Upon failure errno is filled.
+Upon failure 'errno' is filled.
This function is semi-internal, you should rather use functions listed below.
@@ -90,12 +90,12 @@ int GP_SavePNG(const char *dst_path, const GP_Context *src,
-------------------------------------------------------------------------------
Writes a Context into a 'PNG' 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.
+is closed and removed before the call returns non-zero and 'errno' is set to
+'ECANCELED'.
-Currently only 'RGB888' format is supported, you should convert the GP_Context
-to 'RGB888' before calling this function otherwise non-zero is returned and
-errno is set to ENOSYS.
+Currently only 'RGB888' format is supported, you should convert the
+'GP_Context' to 'RGB888' before calling this function otherwise non-zero is
+returned and 'errno' is set to 'ENOSYS'.
JPEG
~~~~
@@ -131,8 +131,8 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback);
Loads 'JPG' file into context the file pointer must point to the start of the
'JPG' data stream (eg. should point right after the signature). The context,
to store the image to, is allocated. The loading process could by aborted by a
-callback, in such case all memory is freed and the call returns NULL and errno
-is set to ECANCELED.
+callback, in such case all memory is freed and the call returns 'NULL' and
+'errno' is set to 'ECANCELED'.
[source,c]
-------------------------------------------------------------------------------
@@ -157,8 +157,8 @@ int GP_SaveJPG(const char *dst_path, const GP_Context *src,
-------------------------------------------------------------------------------
Writes a Context into a 'JPG' 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.
+is closed and removed before the call returns non-zero and 'errno' is set to
+'ECANCELED'.
The 'JPG' format could store either 'G8' or 'RGB888' pixeltypes and you must
convert the context into one of them before this fucntions is called.
@@ -179,7 +179,7 @@ int GP_OpenGIF(const char *src_path, void **f);
Opens file and checks for 'GIF' signature upon successful return (file could
be opened, signature matches) zero is returned and gif handle f is set
-otherwise non-zero is returned and errno is set.
+otherwise non-zero is returned and 'errno' is set.
This function is semi-internal, you should rather use functions listed below.
@@ -195,7 +195,8 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback);
Loads 'GIF' file into context. The pointer must point to the 'GIF' handle as
returned by 'GP_OpenGIF()' function. The context, to store the image to, is
allocated. The loading process could by aborted by a callback, in such case
-all memory is freed and the call returns NULL and errno is set to ECANCELED.
+all memory is freed and the call returns 'NULL' and 'errno' is set to
+'ECANCELED'.
Currently this function loads only first image from the gif container.
@@ -228,8 +229,9 @@ int GP_OpenBMP(const char *src_path, FILE **f,
-------------------------------------------------------------------------------
Opens file and checks for 'BMP' signature upon successful return (file could
-be opened, signature matches) zero is returned and the parameters, if not
-NULL, are initalized. Upon failure non-zero is returned and errno is set.
+be opened, signature matches) zero is returned and the parameters, if
+non-'NULL', are initalized. Upon failure non-zero is returned and 'errno' is
+set.
This function is semi-internal, you should rather use functions listed below.
@@ -242,10 +244,10 @@ This function is semi-internal, you should rather use functions listed below.
GP_Context *GP_ReadBMP(FILE *f, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads 'BMP' file into context. The FILE pointer must point to opened 'BMP'
+Loads 'BMP' file into context. The 'FILE' pointer must point to opened 'BMP'
file. The context, to store the image to, is allocated. The loading process
could by aborted by a callback, in such case all memory is freed and the call
-returns NULL and errno is set to ECANCELED.
+returns 'NULL' and 'errno' is set to 'ECANCELED'.
Currently this function loads only first image from the 'GIF' container.
@@ -264,6 +266,6 @@ signature. Basically this combines both of the calls above.
PBM, PGM, PPM
~~~~~~~~~~~~~
-There is a code do load and write PBM, PGM and PPM images too. However it's
-not finished and it's API is outdated. Use at your own risk.
+There is a code do load and write 'PBM', 'PGM' and 'PPM' images too. However
+it's not finished and it's API is outdated. Use at your own risk.
-----------------------------------------------------------------------
Summary of changes:
doc/basic_types.txt | 1 +
1 files changed, 1 insertions(+), 0 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 f68afbebe846cbdba887cd1f19a26de2f130a182 (commit)
from a1a8790a15c07510bf5d309448cf1a9b460ec344 (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/f68afbebe846cbdba887cd1f19a26de2f130…
commit f68afbebe846cbdba887cd1f19a26de2f130a182
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 5 14:40:43 2012 +0200
doc: A few fixes.
diff --git a/doc/basic_types.txt b/doc/basic_types.txt
index b3328e9..14ae62e 100644
--- a/doc/basic_types.txt
+++ b/doc/basic_types.txt
@@ -111,7 +111,7 @@ If non 'NULL' progress callback structure is passed to a function, the
callback function is periodically called and the percentage is updated.
The return value from callback could abort the function execution. If non zero
-value is returned the filter is aborted, all memory freed etc.
+value is returned the filter is aborted, all memory freed etc. and in case of
+bitmap loaders 'errno' is set to 'ECANCELED'.
The callback, if supported, is the last parameter of a function.
-
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 409c940..7d5d0c5 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -4,15 +4,15 @@ This part of gfxprim library aims to create API to load/save images from/to
common image file formats.
All loading functions returns a pointer to allocated and loaded image or upon
-a failure NULL is returned and errno is set.
+a failure 'NULL' is returned and 'errno' is set.
The possible errno values are:
* anything returned by fopen(), fclose(), fseek(), ...
-* ENOSYS if library wasn't compiled with particual library support
-* ENOMEM as returned by malloc()
-* EIO/EILSEQ invalid image data
-* ECANCELED loading canceled from callback
+* 'ENOSYS' if library wasn't compiled with particual library support
+* 'ENOMEM' as returned by malloc()
+* 'EIO'/'EILSEQ' invalid image data
+* 'ECANCELED' loading canceled from callback
Common Loader
~~~~~~~~~~~~~
@@ -49,7 +49,7 @@ Opens file and checks for 'PNG' signature. Returns zero on success (file
could be opened, signature matches), the opened file is returned and the file
possition points right after the end of the 'PNG' signature.
-Upon failure errno is filled.
+Upon failure 'errno' is filled.
This function is semi-internal, you should rather use functions listed below.
@@ -90,12 +90,12 @@ int GP_SavePNG(const char *dst_path, const GP_Context *src,
-------------------------------------------------------------------------------
Writes a Context into a 'PNG' 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.
+is closed and removed before the call returns non-zero and 'errno' is set to
+'ECANCELED'.
-Currently only 'RGB888' format is supported, you should convert the GP_Context
-to 'RGB888' before calling this function otherwise non-zero is returned and
-errno is set to ENOSYS.
+Currently only 'RGB888' format is supported, you should convert the
+'GP_Context' to 'RGB888' before calling this function otherwise non-zero is
+returned and 'errno' is set to 'ENOSYS'.
JPEG
~~~~
@@ -131,8 +131,8 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback);
Loads 'JPG' file into context the file pointer must point to the start of the
'JPG' data stream (eg. should point right after the signature). The context,
to store the image to, is allocated. The loading process could by aborted by a
-callback, in such case all memory is freed and the call returns NULL and errno
-is set to ECANCELED.
+callback, in such case all memory is freed and the call returns 'NULL' and
+'errno' is set to 'ECANCELED'.
[source,c]
-------------------------------------------------------------------------------
@@ -157,8 +157,8 @@ int GP_SaveJPG(const char *dst_path, const GP_Context *src,
-------------------------------------------------------------------------------
Writes a Context into a 'JPG' 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.
+is closed and removed before the call returns non-zero and 'errno' is set to
+'ECANCELED'.
The 'JPG' format could store either 'G8' or 'RGB888' pixeltypes and you must
convert the context into one of them before this fucntions is called.
@@ -179,7 +179,7 @@ int GP_OpenGIF(const char *src_path, void **f);
Opens file and checks for 'GIF' signature upon successful return (file could
be opened, signature matches) zero is returned and gif handle f is set
-otherwise non-zero is returned and errno is set.
+otherwise non-zero is returned and 'errno' is set.
This function is semi-internal, you should rather use functions listed below.
@@ -195,7 +195,8 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback);
Loads 'GIF' file into context. The pointer must point to the 'GIF' handle as
returned by 'GP_OpenGIF()' function. The context, to store the image to, is
allocated. The loading process could by aborted by a callback, in such case
-all memory is freed and the call returns NULL and errno is set to ECANCELED.
+all memory is freed and the call returns 'NULL' and 'errno' is set to
+'ECANCELED'.
Currently this function loads only first image from the gif container.
@@ -228,8 +229,9 @@ int GP_OpenBMP(const char *src_path, FILE **f,
-------------------------------------------------------------------------------
Opens file and checks for 'BMP' signature upon successful return (file could
-be opened, signature matches) zero is returned and the parameters, if not
-NULL, are initalized. Upon failure non-zero is returned and errno is set.
+be opened, signature matches) zero is returned and the parameters, if
+non-'NULL', are initalized. Upon failure non-zero is returned and 'errno' is
+set.
This function is semi-internal, you should rather use functions listed below.
@@ -242,10 +244,10 @@ This function is semi-internal, you should rather use functions listed below.
GP_Context *GP_ReadBMP(FILE *f, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads 'BMP' file into context. The FILE pointer must point to opened 'BMP'
+Loads 'BMP' file into context. The 'FILE' pointer must point to opened 'BMP'
file. The context, to store the image to, is allocated. The loading process
could by aborted by a callback, in such case all memory is freed and the call
-returns NULL and errno is set to ECANCELED.
+returns 'NULL' and 'errno' is set to 'ECANCELED'.
Currently this function loads only first image from the 'GIF' container.
@@ -264,6 +266,6 @@ signature. Basically this combines both of the calls above.
PBM, PGM, PPM
~~~~~~~~~~~~~
-There is a code do load and write PBM, PGM and PPM images too. However it's
-not finished and it's API is outdated. Use at your own risk.
+There is a code do load and write 'PBM', 'PGM' and 'PPM' images too. However
+it's not finished and it's API is outdated. Use at your own risk.
-----------------------------------------------------------------------
Summary of changes:
doc/basic_types.txt | 4 ++--
doc/loaders.txt | 48 +++++++++++++++++++++++++-----------------------
2 files changed, 27 insertions(+), 25 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 a1a8790a15c07510bf5d309448cf1a9b460ec344 (commit)
via bd082cac18a091c462b65f1f2d9a0adacb9b35fe (commit)
via 115391b21612956d9ed1f541d9272001e15c3c83 (commit)
via 473dac1a93ecc9a00bcbdc4c3fc1acd110afbd53 (commit)
via 268542916484c84a4b205bba09a9b700f3530b76 (commit)
via 075f6abdea6c012df7201450896669431336b6eb (commit)
from e77e1ccb700947ccd7286bf64c06d2d21d73c175 (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/a1a8790a15c07510bf5d309448cf1a9b460e…
commit a1a8790a15c07510bf5d309448cf1a9b460ec344
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 5 14:11:40 2012 +0200
doc: Update context docs.
diff --git a/doc/context.txt b/doc/context.txt
index 38a8efb..6395eee 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -1,7 +1,7 @@
Drawing Context
---------------
-GP_Context is data structure for storing 'in memory' bitmaps.
+The 'GP_Context' is data structure for storing 'in memory' bitmaps.
Data Structure
~~~~~~~~~~~~~~
@@ -26,6 +26,7 @@ typedef struct GP_Context {
uint8_t axes_swap:1; /* swap axes */
uint8_t x_swap:1; /* mirror x */
uint8_t y_swap:1; /* mirror y */
+ uint8_t bit_endian:1; /* GP_BIT_ENDIAN */
uint8_t free_pixels:1; /* if set GP_ContextFree() calls free on context->pixels */
} GP_Context;
-------------------------------------------------------------------------------
@@ -36,12 +37,12 @@ stored in one dimensional array in byte-aligned lines.
Rotation
^^^^^^^^
-The orientation flags affects the gfx and text drawing functions. If some of
-the flags is changed the origin and direction of the drawing is changed. Note
-that the image pixels are not affected by this at all only the coordinates
-passed to drawing functions are transformed accordingly.
+The orientation flags affects the gfx and text drawing functions and blits. If
+some of the flags is changed the origin and direction of the drawing is
+changed. Note that the image pixels are not affected by this at all only the
+coordinates passed to drawing functions are transformed accordingly.
-If you don't need this functionality just don't touch these flags the as
+If you don't need this functionality just don't touch the flags the as
overhead of these transformations is not measurable.
If you really need drawing primitives that do not use the orientation flags,
@@ -54,6 +55,10 @@ when taking into the accout the widht and height.
[source,c]
-------------------------------------------------------------------------------
+#include <core/GP_Transform.h>
+/* or */
+#include <GP.h>
+
/* Transforms point user coordinates to bitmap coordinates */
GP_TRANSFORM_POINT(context, x, y)
@@ -65,7 +70,11 @@ GP_RETRANSFORM_POINT(context, x, y)
-------------------------------------------------------------------------------
[source,c]
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
+#include <core/GP_Context.h>
+/* or */
+#include <GP.h>
+
/*
* Rotate context flags clock wise.
*/
@@ -88,27 +97,60 @@ Context base functions
[source,c]
-------------------------------------------------------------------------------
+#include <core/GP_Context.h>
+/* or */
+#include <GP.h>
+
+void GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h,
+ GP_PixelType type, void *pixels);
+-------------------------------------------------------------------------------
+
+Initalize given context accordingly to parameters, the rest of context
+parameters are set to the default values. Eg. rotation flags are all set to
+zero as well as the free_pixels flag. The bpp and bytes_per_row are computed
+from the given pixel type and size. The pixels pointer may be NULL and could
+be changed later manually.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <core/GP_Context.h>
+/* or */
#include <GP.h>
GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type);
+-------------------------------------------------------------------------------
-GP_Context *GP_ContextCopy(const GP_Context *src, int flag);
+The 'GP_ContextAlloc()' allocates context and initalizes a context.
-void GP_ContextFree(GP_Context *context);
+The orientation flags are all set to zero, the free_pixels flag is set and the
+rest of the metadata are calculated accordingly to width, height and
+pixel_type.The contxt->pixels pointer points to newly allocated bitmap with
+appropriate size; the initial contents of the bitmap are undefined.
+
+[source,c]
-------------------------------------------------------------------------------
+#include <core/GP_Context.h>
+/* or */
+#include <GP.h>
-The 'GP_ContextAlloc()' allocates context and initalizes the context
-structure. The orientation flags are all set to 0 and the rest of the metadata
-are calculated accordingly to width, height and pixel_type. A bitmap with
-appropriate size is allocated and stored in context->pixels; the initial
-contents of the bitmap are undefined.
+GP_Context *GP_ContextCopy(const GP_Context *src, int flag);
+-------------------------------------------------------------------------------
The 'GP_ContextCopy()' allocates and initalizes a copy of the context passed
as argument. If 'flag' is not zero, the bitmap (context->pixels) is copied
otherwise it's left uninitalized.
-In both cases the resulting context should later be freed with
-'GP_ContextFree()'.
+[source,c]
+-------------------------------------------------------------------------------
+#include <core/GP_Context.h>
+/* or */
+#include <GP.h>
+
+void GP_ContextFree(GP_Context *context);
+-------------------------------------------------------------------------------
+
+Frees the context memory. If free_pixels flag is set, the pixels datada are
+freed too.
Subcontext
~~~~~~~~~~
@@ -122,6 +164,8 @@ it belongs to another context; it will be freed with the hosting context.
[source,c]
-------------------------------------------------------------------------------
+#include <core/GP_Context.h>
+/* or */
#include <GP.h>
GP_Context *GP_ContextSubContext(GP_Context *context, GP_Context *subcontext,
@@ -142,15 +186,17 @@ Conversions
[source,c]
-------------------------------------------------------------------------------
+#include <core/GP_Context.h>
+/* or */
#include <GP.h>
GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst,
GP_PixelType dst_pixel_type);
-------------------------------------------------------------------------------
-Provides basic context conversion functionality.
-A newly allocated context is returned.
+Provides basic context conversion functionality. A newly allocated context is
+returned.
-This fuction does no error distribution but only integer
-division/multiplication for each pixel channel.
+This fuction does no error distribution but only multiply or rounds the pixel
+values. If you need something better use Floyd Steinberg dithering instead.
http://repo.or.cz/w/gfxprim.git/commit/bd082cac18a091c462b65f1f2d9a0adacb9b…
commit bd082cac18a091c462b65f1f2d9a0adacb9b35fe
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 5 14:02:03 2012 +0200
doc: Fix a few typos in basic types.
diff --git a/doc/basic_types.txt b/doc/basic_types.txt
index 0ef0930..b3328e9 100644
--- a/doc/basic_types.txt
+++ b/doc/basic_types.txt
@@ -54,7 +54,7 @@ successful match and conversion and false otherwise.
[source,c]
--------------------------------------------------------------------------------
-#include <GP_Color.h>
+#include <core/GP_Color.h>
/* or */
#include <GP.h>
@@ -75,7 +75,7 @@ returns true if color with such name was found.
[source,c]
--------------------------------------------------------------------------------
-#include <GP_Color.h>
+#include <core/GP_Color.h>
/* or */
#include <GP.h>
http://repo.or.cz/w/gfxprim.git/commit/115391b21612956d9ed1f541d9272001e15c…
commit 115391b21612956d9ed1f541d9272001e15c3c83
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 5 14:01:27 2012 +0200
doc: Fix a few typos in loaders.
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 4b9422c..409c940 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -19,6 +19,8 @@ Common Loader
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_Loaders.h>
+/* or */
#include <GP.h>
GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback);
@@ -36,6 +38,8 @@ are not supported yet.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_PNG.h>
+/* or */
#include <GP.h>
int GP_OpenPNG(const char *src_path, FILE **f);
@@ -51,6 +55,8 @@ This function is semi-internal, you should rather use functions listed below.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_PNG.h>
+/* or */
#include <GP.h>
GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback);
@@ -63,6 +69,8 @@ callback, in such case all memory is freed.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_PNG.h>
+/* or */
#include <GP.h>
GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback);
@@ -73,6 +81,8 @@ signature. Basically this combines both of the calls above.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_PNG.h>
+/* or */
#include <GP.h>
int GP_SavePNG(const char *dst_path, const GP_Context *src,
@@ -87,12 +97,14 @@ Currently only 'RGB888' format is supported, you should convert the GP_Context
to 'RGB888' before calling this function otherwise non-zero is returned and
errno is set to ENOSYS.
-JPG
-~~~
-The 'PNG' loading support is optionaly implemented by jpeg library.
+JPEG
+~~~~
+The 'JPEG' loading support is optionaly implemented by jpeg library.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_JPG.h>
+/* or */
#include <GP.h>
int GP_OpenJPG(const char *src_path, FILE **f);
@@ -109,6 +121,8 @@ file and the 'GP_ReadJPG()' reads the signature instead.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_JPG.h>
+/* or */
#include <GP.h>
GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback);
@@ -122,6 +136,8 @@ is set to ECANCELED.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_JPG.h>
+/* or */
#include <GP.h>
GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback);
@@ -132,6 +148,8 @@ signature. Basically this combines both of the calls above.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_JPG.h>
+/* or */
#include <GP.h>
int GP_SaveJPG(const char *dst_path, const GP_Context *src,
@@ -152,6 +170,8 @@ The 'GIF' format is supported optionaly by giflib library.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_GIF.h>
+/* or */
#include <GP.h>
int GP_OpenGIF(const char *src_path, void **f);
@@ -165,6 +185,8 @@ This function is semi-internal, you should rather use functions listed below.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_GIF.h>
+/* or */
#include <GP.h>
GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback);
@@ -179,6 +201,8 @@ Currently this function loads only first image from the gif container.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_GIF.h>
+/* or */
#include <GP.h>
GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback);
@@ -195,6 +219,8 @@ be fancy RGB compressions and RLE support.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_BMP.h>
+/* or */
#include <GP.h>
int GP_OpenBMP(const char *src_path, FILE **f,
@@ -209,6 +235,8 @@ This function is semi-internal, you should rather use functions listed below.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_BMP.h>
+/* or */
#include <GP.h>
GP_Context *GP_ReadBMP(FILE *f, GP_ProgressCallback *callback);
@@ -223,6 +251,8 @@ Currently this function loads only first image from the 'GIF' container.
[source,c]
-------------------------------------------------------------------------------
+#include <loaders/GP_BMP.h>
+/* or */
#include <GP.h>
GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback);
http://repo.or.cz/w/gfxprim.git/commit/473dac1a93ecc9a00bcbdc4c3fc1acd110af…
commit 473dac1a93ecc9a00bcbdc4c3fc1acd110afbd53
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 5 13:51:55 2012 +0200
doc: Update basic types docs.
diff --git a/doc/basic_types.txt b/doc/basic_types.txt
index 8f7283c..0ef0930 100644
--- a/doc/basic_types.txt
+++ b/doc/basic_types.txt
@@ -1,63 +1,50 @@
Basic types
-----------
-Return Code
-~~~~~~~~~~~
+Coordinates and Size/Length
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Some gfxprim function returns one of following return codes (may be removed in
-future):
+Most of the drawing functions use typedefed 'GP_Coord' and 'GP_Size' integer
+types for parameters.
-[source,c]
---------------------------------------------------------------------------------
-typedef enum GP_RetCode {
- GP_ESUCCESS,
- GP_EINVAL,
- GP_ENOIMPL,
- GP_EUNPRECISE,
- GP_ENULLPTR, /* some argument was unexpectedly NULL */
- GP_EBACKENDLOST,
- GP_EBADCONTEXT, /* context contains invalid data */
- GP_EBADFILE, /* error in file, or bad file format */
- GP_ENOENT, /* no such file or another object */
- GP_ENOMEM, /* not enough memory */
- GP_EINTR, /* interrupted by a callback */
- GP_EMAX,
-} GP_RetCode;
---------------------------------------------------------------------------------
-
-Return codes could be translated into an error messages.
-
-[source,c]
---------------------------------------------------------------------------------
-const char *GP_RetCodeName(GP_RetCode code);
---------------------------------------------------------------------------------
+The 'GP_Coord' is signed integer which is used for coordinates and the
+'GP_Size' is unsigned integer type used for object size, length and so.
-Coord and Size
-~~~~~~~~~~~~~~
-For drawing API there are two integer types defined the 'GP_Coord' for
-coordinates and 'GP_Size' for size, length or so.
+Pixel
+~~~~~
-Color and pixel types
-~~~~~~~~~~~~~~~~~~~~~
+Pixel value in 'GFXprim' is an integer big enough to hold the actual pixel
+values. The default typedef for 'GP_Pixel' is set to 32 bit integer, which may
+be changed at compile time to support colors with more than 10 bits per
+channel. The 'GP_Pixel' is thus used as opaque value big enough to hold any
+supported pixel value.
-The color, in gfxprim is enumeration of symbolic color names while pixel is
-integer value or you may say color in format of the target bitmap.
+Color
+~~~~~
-Color could be converted into given pixel type which will result in integer
-value suitable for usage with drawing functions. The color could be also
-converted to color name (C string in English language) and C string may be
-matched against table of color names.
+The 'GP_Color', in gfxprim is enumeration of symbolic color names.
-As all drawing functions works with pixel rather than color the color must be
-converted before using function to draw a shape into a bitmap.
+Color could be converted for a given 'GP_PixelType' which will result into
+'GP_Pixel' value suitable for usage with drawing functions. The color could be
+also converted to color name (C string in English language) and C string may
+be matched against table of color names.
-The color is defined as follows:
+The 'GP_Color' enmum is defined as follows:
[source,c]
--------------------------------------------------------------------------------
typedef enum GP_Color {
GP_COL_INVALID = -1,
GP_COL_BLACK,
- ...
+ GP_COL_RED,
+ GP_COL_GREEN,
+ GP_COL_BLUE,
+ GP_COL_YELLOW,
+ GP_COL_BROWN,
+ GP_COL_ORANGE,
+ GP_COL_GRAY_DARK,
+ GP_COL_GRAY_LIGHT,
+ GP_COL_PURPLE,
+ GP_COL_WHITE,
GP_COL_MAX,
} GP_Color;
--------------------------------------------------------------------------------
@@ -68,6 +55,8 @@ successful match and conversion and false otherwise.
[source,c]
--------------------------------------------------------------------------------
#include <GP_Color.h>
+/* or */
+#include <GP.h>
GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type);
GP_Pixel GP_ColorToContextPixel(GP_Color color, GP_Context *context);
@@ -87,6 +76,8 @@ returns true if color with such name was found.
[source,c]
--------------------------------------------------------------------------------
#include <GP_Color.h>
+/* or */
+#include <GP.h>
void GP_ColorLoadPixels(GP_Pixel pixels[], GP_PixelType pixel_type);
void GP_ColorLoadContextPixels(GP_Pixel pixels[], GP_Context *context);
@@ -98,8 +89,8 @@ the GP_Color enum as 'pixels[GP_COL_BLACK]'.
Progress Callback
~~~~~~~~~~~~~~~~~
-Progress callback is a structure that stores user-defined callback function,
-pointer to store location of user data and percentage.
+The 'GP_ProgressCallback' is a structure that stores user-defined callback
+function and user-defined pointer and percentage.
It is passed as last parameter to functions that could take some time to
complete and adds capability to track the operation progress as well as to
@@ -120,9 +111,7 @@ If non 'NULL' progress callback structure is passed to a function, the
callback function is periodically called and the percentage is updated.
The return value from callback could abort the function execution. If non zero
-value is returned the filter is aborted, all memory freed etc. and the
-function either returns 'NULL' if pointer is returned or 'GP_EINTR' in case
-filter returns 'GP_RetCode'.
+value is returned the filter is aborted, all memory freed etc.
The callback, if supported, is the last parameter of a function.
http://repo.or.cz/w/gfxprim.git/commit/268542916484c84a4b205bba09a9b700f353…
commit 268542916484c84a4b205bba09a9b700f3530b76
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 5 13:36:00 2012 +0200
doc: Updated general gfxprim description.
diff --git a/doc/general.txt b/doc/general.txt
index 5e6f356..c8b6262 100644
--- a/doc/general.txt
+++ b/doc/general.txt
@@ -1,43 +1,81 @@
General information
-------------------
-Gfxprim is simple 2D bitmap graphics library with emphasis on speed and
-correctness.
+Gfxprim is simple modular 2D bitmap graphics library with emphasis on speed
+and correctness.
+
+One of the key points of the library is code generation. Most of the graphics
+operations are written using 'jinja' templating engine which is used to
+generate specialized C code. So, for an example, once you add pixel
+definition into configuration file, creating specialized filters, loaders and
+conversions to other pixel formats is just a matter of typing "make && make
+clean".
+
+The library also includes, fairly optimized, fixed-point image filters, namely
+various resampling algorithms used to resize images, low pass filters, etc...
Implemented features
~~~~~~~~~~~~~~~~~~~~
-* basic graphics primitives (with and without fill)
-** line, circle, ellipse, triangle, tetragon
-* text drawing
-** supports both proportional and non proportional fonts
-** basic font is compiled in the library
-** font rendering can be altered by style attributes
-** font can be loaded from or stored in file
-** convertor from bdf is on the way
-* various bitmap formats to draw on
-* SDL drawing backend
-* bitmaps and blitting
-** create, destroy bitmap
-** bitmap rotation (in order to speed up rotated blits)
-Work in progress
-~~~~~~~~~~~~~~~~
+Graphics Rendering
+^^^^^^^^^^^^^^^^^^
+* Basic Graphics Primitives (with and without fill)
+** PutPixel/GetPixel
+** Lines
+** Circles
+** Elipses
+** Polygon
+
+* Text Drawing
+** Supports both proportional and non proportional fonts
+** Basic fonts are compiled in the library
+** Font rendering can be altered by style attributes
+** Supports, for example, pixel multiplication and tracking
+** Includes basic suppport for freetype
+
+* Bitmaps and Blitting
+** Create, Destroy bitmap
+** Subcontext, rectangular region in one context could be used as a context
+** Fast specialized blits (with 90, 180 and 270 degree rotation)
+
+Bitmap Filters
+^^^^^^^^^^^^^^
+* Point filters
+** Brightness
+** Contrast
+** General Point filter
-* bitmaps and blitting
-** blit bitmaps (should respect rotation and pixel formats)
-** loading bitmaps from image files (jpg, png, bmp, pnm ...)
+* Linear filters
+** Specialized Gaussian blur
+** Separable Convolution
+** General Convolution
-* backends
-** finish frame-buffer backend (SDL does not work on most of my frame-buffers)
-** other than SDL X backend (SDL does support only one window)
-** some overall initialization routines
+* Arihtmetics filters
+** Addition
+** Multiplication
+** Difference
+** Maximum, Minimum
+
+* Floyd Steinberg dithering
+
+* Bitmap resampling algorithms
+** Nearest Neighbour
+** Bilinear
+** Cubic
+
+* Bitmap rotation and mirroring
+** 90 180 and 170 degree rotation
+
+* Histogram generator
+
+Work in progress
+~~~~~~~~~~~~~~~~
-Advanced (and unimplemented) features
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Python bindings
+** basic support works now
+** could be combined with PyGTK for GUI drawing (experimental)
-* bitmaps
-** alpha channel
+* Anti Aliased drawing
+** Line and PutPixel are finished
-* gfx primitives
-** drawing with alpha channel
-** anti aliasing
+* Gamma correction and color profiles
http://repo.or.cz/w/gfxprim.git/commit/075f6abdea6c012df7201450896669431336…
commit 075f6abdea6c012df7201450896669431336b6eb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 5 11:59:44 2012 +0200
doc: Update loaders docs.
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 7a752e8..4b9422c 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -1,92 +1,101 @@
Context loaders
---------------
This part of gfxprim library aims to create API to load/save images from/to
-common image fileformats.
+common image file formats.
+
+All loading functions returns a pointer to allocated and loaded image or upon
+a failure NULL is returned and errno is set.
+
+The possible errno values are:
+
+* anything returned by fopen(), fclose(), fseek(), ...
+* ENOSYS if library wasn't compiled with particual library support
+* ENOMEM as returned by malloc()
+* EIO/EILSEQ invalid image data
+* ECANCELED loading canceled from callback
Common Loader
~~~~~~~~~~~~~
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_LoadImage(const char *src_path, GP_Context **res,
- GP_ProgressCallback *callback);
+GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads image from a file. The image format is now recognized by the file
-filename extension. Format detection using file signature is planned.
-
-The loading process could be aborted by process callback.
+Loads image from a file. The format is now matched by an image file extension.
+File sinature loading method is on the TODO.
PNG
~~~
+The 'PNG' loading support is optionaly implemented by libpng.
-Just now, the 'PNG' support is not fully finished, the Alpha channel as well
-as palletes doesn't work well or at all, we are working on that.
+Just now, the 'PNG' support is not fully finished. Images with alpha channel
+are not supported yet.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_OpenPNG(const char *src, FILE **f);
+int GP_OpenPNG(const char *src_path, FILE **f);
-------------------------------------------------------------------------------
-Opens file and checks for 'PNG' signature upon successful return (file could
-be opened, signature matches), the opened file is returned and the file
+Opens file and checks for 'PNG' signature. Returns zero on success (file
+could be opened, signature matches), the opened file is returned and the file
possition points right after the end of the 'PNG' signature.
+Upon failure errno is filled.
+
This function is semi-internal, you should rather use functions listed below.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_ReadPNG(FILE *f, GP_Context **res,
- GP_ProgressCallback *callback);
+GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Loads 'PNG' file into context the file pointer must point to the start of the
'PNG' data stream (eg. should point right after the signature). The context,
to store the image to, is allocated. The loading process could by aborted by a
-callback, in such case all memory is freed and the call returns 'GP_EINTR'.
+callback, in such case all memory is freed.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_LoadPNG(const char *src_path, GP_Context **res,
- GP_ProgressCallback *callback);
+GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Same as abowe but takes path to the file as a parameter and check for the
-signature. Basically this combines both of the calls abowe.
+signature. Basically this combines both of the calls above.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_SavePNG(const char *dst_path, GP_Context *src,
- GP_ProgressCallback *callback);
+int GP_SavePNG(const char *dst_path, const GP_Context *src,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Writes a Context into a 'PNG' image. If aborted by a callback, the opened file
-is closed and removed before the call returns 'GP_EINTR'.
+is closed and removed before the call returns non-zero and errno is set to
+ECANCELED.
Currently only 'RGB888' format is supported, you should convert the GP_Context
-to 'RGB888' before calling this function otherwise 'GP_ENOIMPL' will be
-returned.
+to 'RGB888' before calling this function otherwise non-zero is returned and
+errno is set to ENOSYS.
JPG
~~~
-
-The 'JPG' format is supported for both 'G8' as well as 'RGB888' pixel formats.
+The 'PNG' loading support is optionaly implemented by jpeg library.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_OpenJPG(const char *src, FILE **f);
+int GP_OpenJPG(const char *src_path, FILE **f);
-------------------------------------------------------------------------------
Opens file and checks for 'JPG' signature upon successful return (file could
@@ -100,23 +109,22 @@ file and the 'GP_ReadJPG()' reads the signature instead.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_ReadJPG(FILE *f, GP_Context **res,
- GP_ProgressCallback *callback);
+GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Loads 'JPG' file into context the file pointer must point to the start of the
-'JPG' data stream (eg. should point right after the signature). The context, to
-store the image to, is allocated. The loading process could by aborted by a
-callback, in such case all memory is freed and the call returns 'GP_EINTR'.
+'JPG' data stream (eg. should point right after the signature). The context,
+to store the image to, is allocated. The loading process could by aborted by a
+callback, in such case all memory is freed and the call returns NULL and errno
+is set to ECANCELED.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_LoadJPG(const char *src_path, GP_Context **res,
- GP_ProgressCallback *callback);
+GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Same as abowe but takes path to the file as a parameter and check for the
@@ -124,96 +132,108 @@ signature. Basically this combines both of the calls above.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_SaveJPG(const char *dst_path, GP_Context *src,
- GP_ProgressCallback *callback);
+int GP_SaveJPG(const char *dst_path, const GP_Context *src,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Writes a Context into a 'JPG' image. If aborted by a callback, the opened file
-is closed and removed before the call returns 'GP_EINTR'.
+is closed and removed before the call returns non-zero and errno is set to
+ECANCELED.
The 'JPG' format could store either 'G8' or 'RGB888' pixeltypes and you must
convert the context into one of them before this fucntions is called.
-'TODO:' add parameters to change the encoding settings.
-
-PBM
+GIF
~~~
-PBM -- portable bitmap file format.
+The 'GIF' format is supported optionaly by giflib library.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_LoadPBM(const char *src, GP_Context **res);
+int GP_OpenGIF(const char *src_path, void **f);
-------------------------------------------------------------------------------
-This function allocates and loads a 'GP_Context' with 'GP_PIXEL_G1' pixels. If
-the return code is not zero ('GP_ESUCCESS') an error during loading the bitmap
-happend.
+Opens file and checks for 'GIF' signature upon successful return (file could
+be opened, signature matches) zero is returned and gif handle f is set
+otherwise non-zero is returned and errno is set.
-The returned 'GP_Context' should be later freed with 'GP_ContextFree()'.
+This function is semi-internal, you should rather use functions listed below.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_SavePBM(const char *res, GP_Context *src);
+GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Save 'GP_Context' into PBM file. The 'GP_Context' pixel type must be
-'GP_PIXEL_G1', otherwise 'GP_ENOIMPL' error is returned.
+Loads 'GIF' file into context. The pointer must point to the 'GIF' handle as
+returned by 'GP_OpenGIF()' function. The context, to store the image to, is
+allocated. The loading process could by aborted by a callback, in such case
+all memory is freed and the call returns NULL and errno is set to ECANCELED.
-PGM
-~~~
-PBM -- portable graymap file format.
+Currently this function loads only first image from the gif container.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_LoadPGM(const char *src, GP_Context **res);
+GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-While the format allows to have any integer bit depth, only following color
-depths are supported:
-
-* GP_PIXEL_1G
-* GP_PIXEL_2G
-* GP_PIXEL_4G
-* GP_PIXEL_8G
+Same as abowe but takes path to the file as a parameter and check for the
+signature. Basically this combines both of the calls above.
-This function allocates and loads a 'GP_Context'. If the return code is not
-zero ('GP_ESUCCESS') an error during loading the bitmap happend.
+BMP
+~~~
-The returned 'GP_Context' should be later freed with 'GP_ContextFree()'.
+The 'BMP' loading support is nearly complete the only missing features should
+be fancy RGB compressions and RLE support.
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Loaders.h>
+#include <GP.h>
-GP_RetCode GP_SavePGM(const char *res, GP_Context *src);
+int GP_OpenBMP(const char *src_path, FILE **f,
+ GP_Size *w, GP_Size *h, GP_PixelType *pixel_type);
-------------------------------------------------------------------------------
-Save 'GP_Context' into PGM file. The pixel type must be one of:
+Opens file and checks for 'BMP' signature upon successful return (file could
+be opened, signature matches) zero is returned and the parameters, if not
+NULL, are initalized. Upon failure non-zero is returned and errno is set.
-* GP_PIXEL_1G
-* GP_PIXEL_2G
-* GP_PIXEL_4G
-* GP_PIXEL_8G
+This function is semi-internal, you should rather use functions listed below.
-Otherwise 'GP_ENOIMPL' is returned.
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
-PNM
-~~~
+GP_Context *GP_ReadBMP(FILE *f, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
-To be implemented.
+Loads 'BMP' file into context. The FILE pointer must point to opened 'BMP'
+file. The context, to store the image to, is allocated. The loading process
+could by aborted by a callback, in such case all memory is freed and the call
+returns NULL and errno is set to ECANCELED.
-PPM
-~~~
+Currently this function loads only first image from the 'GIF' container.
-To be implemented.
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+
+GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Same as abowe but takes path to the file as a parameter and check for the
+signature. Basically this combines both of the calls above.
+
+PBM, PGM, PPM
+~~~~~~~~~~~~~
+There is a code do load and write PBM, PGM and PPM images too. However it's
+not finished and it's API is outdated. Use at your own risk.
-----------------------------------------------------------------------
Summary of changes:
doc/basic_types.txt | 91 +++++++++-----------
doc/context.txt | 86 +++++++++++++++-----
doc/general.txt | 100 +++++++++++++++-------
doc/loaders.txt | 230 +++++++++++++++++++++++++++++++--------------------
4 files changed, 315 insertions(+), 192 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 e77e1ccb700947ccd7286bf64c06d2d21d73c175 (commit)
from b02d3680c656b2274293750005a57cd3ff602631 (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/e77e1ccb700947ccd7286bf64c06d2d21d73…
commit e77e1ccb700947ccd7286bf64c06d2d21d73c175
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 4 18:09:52 2012 +0200
doc: Initial docs for backends.
diff --git a/doc/api.txt b/doc/api.txt
index 19142f6..c2fca5c 100644
--- a/doc/api.txt
+++ b/doc/api.txt
@@ -8,3 +8,4 @@ include::context.txt[]
include::drawing_api.txt[]
include::filters.txt[]
include::loaders.txt[]
+include::backends.txt[]
diff --git a/doc/backends.txt b/doc/backends.txt
new file mode 100644
index 0000000..f476b10
--- /dev/null
+++ b/doc/backends.txt
@@ -0,0 +1,130 @@
+Drawing Backends
+----------------
+
+Drawing backends provide means to draw into computer screen or into an window
+inside of running operating system. Instead of having one unified
+initalization interface each backend has it's specific function and sematics
+but once backend is initalized the backend structure provides unified API for
+controling the drawing.
+
+So far there are three backends implemented, linux mmaped framebuffer, libSDL
+and X11 backend.
+
+Initalization functions
+~~~~~~~~~~~~~~~~~~~~~~~
+
+[source,c]
+-------------------------------------------------------------------------------
+GP_Backend *GP_BackendLinuxFBInit(const char *path);
+-------------------------------------------------------------------------------
+
+Initalizes mmaped framebuffer backend. The path is path to the framebuffer
+device ie. '/dev/fbX'. This backend is not buffered, everything you draw
+appears on the screen right away (an swich may be added for that purpose).
+
+Also note that this backend doesn't initalize any input driver. You need to
+initalize input driver in order to get keystrokes and/or pointer events.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+enum GP_BackendSDLFlags {
+ GP_SDL_FULLSCREEN = 0x01,
+ GP_SDL_RESIZABLE = 0x02,
+};
+
+GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h,
+ uint8_t bpp, uint8_t flags,
+ const char *caption);
+-------------------------------------------------------------------------------
+
+Initalize SDL as an backend driver. The backend is thread safe as all the
+operations are guarded by locks. You can't initalize more than one backend at a
+time, that is inherited SDL limiation. If you call the initalizaiton for a
+second time, you will get a pointer to allready running backend. This driver
+feeds input events into global input event queue (see input docs for details).
+If w, h and/or bpp are zero SDL tries to do a guess, most of the time wrong for
+w and h though. The caption is window caption and may be ignored for some of
+the backends. And finally flags may change the SDL to go to fullscreen mode or
+make the window resizeable.
+
+[source,c]
+-------------------------------------------------------------------------------
+GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
+ unsigned int w, unsigned int h,
+ const char *caption);
+-------------------------------------------------------------------------------
+
+Returns pointer to backend. When display is NULL default display is used
+(which is what you want most of the time). This backend feeds key events into
+global input queue (pointer events not implemented yet). Note this is
+experimental version of X11 backend and will be changed to support more
+windows at a time.
+
+
+Overall init function
+~~~~~~~~~~~~~~~~~~~~~
+
+Althoug there is no unified backend initalization, there is something close to
+it.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+
+GP_Backend *GP_BackendInit(const char *params, const char *caption, FILE *help);
+-------------------------------------------------------------------------------
+
+This function takes a params string as an parameter which is used for
+determining backend-dependend parametrs. The format is
+'backend_name:backend_parameters' where backend parameters may be size (either
+'WxH' or 'FS' in case of SDL backend). The caption is window caption (which is
+ignored in most of the cases) and the FILE is file, where an error is printed
+in case of failure, you should mostly use 'stderr' for that purpose. If params
+is set to NULL the the call only prints help into the passed help FILE. If
+intitalizaton was succesfull pointer to allocated and initalized backend is
+returned otherwise NULL is returned and some helpful infomation should be
+printed into the passed help FILE.
+
+
+Drawing Backend API
+~~~~~~~~~~~~~~~~~~~
+
+The drawing backend API consist of structure with callbacks. Every backend
+initalization yields pointer to this structure. Although is possible to call
+these pointers directly it's not recomended and everbody should rather use
+backend inline functions instead.
+
+The backend API consist of several functions:
+
+[source,c]
+-------------------------------------------------------------------------------
+void GP_BackendExit(GP_Backend *backend);
+-------------------------------------------------------------------------------
+
+Calls an backend exit callback.
+
+[source,c]
+-------------------------------------------------------------------------------
+GP_BackendFlip(GP_Backend *backend);
+-------------------------------------------------------------------------------
+
+Flips a screen. Updates rect for a buffered backends.
+
+[source,c]
+-------------------------------------------------------------------------------
+void GP_BackendUpdateRect(GP_Backend *backend,
+ GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1);
+-------------------------------------------------------------------------------
+
+Updates particular rectangle for a buffered backends.
+
+[source,c]
+-------------------------------------------------------------------------------
+void GP_BackendPoll(GP_Backend *backend);
+-------------------------------------------------------------------------------
+
+Polls for backend events. For backends that do not expose file descriptor
+(namely SDL) this should be called repeatedly. For other backend it may be
+called either repeatedly or when data are ready on filedescriptor.
-----------------------------------------------------------------------
Summary of changes:
doc/api.txt | 1 +
doc/backends.txt | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 131 insertions(+), 0 deletions(-)
create mode 100644 doc/backends.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
discards 71fb36b2881535c76334f93cc3808dc22941f31d (commit)
via b02d3680c656b2274293750005a57cd3ff602631 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (71fb36b2881535c76334f93cc3808dc22941f31d)
N -- N -- N (b02d3680c656b2274293750005a57cd3ff602631)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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/b02d3680c656b2274293750005a57cd3ff60…
commit b02d3680c656b2274293750005a57cd3ff602631
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 4 17:06:29 2012 +0200
backends: Improve X11 backend.
* Fix region update to update only the actuall region
* Add basic key event support
* Fix compilation without Xlib.
diff --git a/include/input/GP_InputDriverX11.h b/include/input/GP_InputDriverX11.h
new file mode 100644
index 0000000..117a3e0
--- /dev/null
+++ b/include/input/GP_InputDriverX11.h
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+
+ */
+
+#ifndef GP_INPUT_DRIVER_X11_H
+#define GP_INPUT_DRIVER_X11_H
+
+#include <stdint.h>
+#include <X11/Xlib.h>
+
+/*
+ * Converts X11 event to GFXprim event and puts it into the queue.
+ */
+void GP_InputDriverX11EventPut(XEvent *ev);
+
+#endif /* GP_INPUT_DRIVER_X11_H */
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 30bd65d..f12ade8 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -20,11 +20,16 @@
* *
*****************************************************************************/
+#include "../../config.h"
+
+#ifdef HAVE_LIBX11
+
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include "GP_X11.h"
#include "core/GP_Debug.h"
+#include "input/GP_InputDriverX11.h"
+#include "GP_X11.h"
struct x11_priv {
Display *dpy;
@@ -50,13 +55,29 @@ static void x11_exit(GP_Backend *self)
free(self);
}
+static void x11_update_rect(GP_Backend *self, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1)
+{
+ struct x11_priv *x11 = GP_BACKEND_PRIV(self);
+
+ GP_DEBUG(4, "Updating rect %ix%i-%ix%i", x0, y0, x1, y1);
+
+ XLockDisplay(x11->dpy);
+
+ XPutImage(x11->dpy, x11->win, DefaultGC(x11->dpy, x11->scr),
+ x11->img, x0, y0, x0, y0, x1-x0, y1-y0);
+ XFlush(x11->dpy);
+
+ XUnlockDisplay(x11->dpy);
+}
+
static void x11_flip(GP_Backend *self)
{
struct x11_priv *x11 = GP_BACKEND_PRIV(self);
unsigned int w = x11->context->w;
unsigned int h = x11->context->h;
- GP_DEBUG(3, "Flipping context");
+ GP_DEBUG(4, "Flipping context");
XLockDisplay(x11->dpy);
@@ -79,11 +100,21 @@ static void x11_poll(GP_Backend *self)
switch (ev.type) {
case Expose:
- x11_flip(self);
+ GP_DEBUG(4, "Expose %ix%i-%ix%i %i",
+ ev.xexpose.x, ev.xexpose.y,
+ ev.xexpose.width, ev.xexpose.height,
+ ev.xexpose.count);
+ x11_update_rect(self, ev.xexpose.x, ev.xexpose.y,
+ ev.xexpose.x + ev.xexpose.width,
+ ev.xexpose.y + ev.xexpose.height);
break;
case MapNotify:
GP_DEBUG(1, "Shown");
break;
+ case KeyPress:
+ case KeyRelease:
+ GP_InputDriverX11EventPut(&ev);
+ break;
}
}
@@ -142,7 +173,8 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
}
/* Select events */
- XSelectInput(x11->dpy, x11->win, StructureNotifyMask|ExposureMask);
+ XSelectInput(x11->dpy, x11->win, StructureNotifyMask | ExposureMask |
+ KeyPressMask | KeyReleaseMask);
/* Set window caption */
XmbSetWMProperties(x11->dpy, x11->win, caption, caption,
@@ -153,7 +185,6 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
XFlush(x11->dpy);
/*
-
enum GP_PixelType pixel_type;
pixel_type = GP_PixelRGBLookup(vscri.red.length, vscri.red.offset,
vscri.green.length, vscri.green.offset,
@@ -172,7 +203,7 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
backend->name = "X11";
backend->context = x11->context;
backend->Flip = x11_flip;
- backend->UpdateRect = NULL;
+ backend->UpdateRect = x11_update_rect;
backend->Exit = x11_exit;
backend->fd_list = NULL;
backend->Poll = x11_poll;
@@ -188,3 +219,16 @@ err0:
free(backend);
return NULL;
}
+
+#else
+
+#include "GP_Backend.h"
+
+GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
+ unsigned int w, unsigned int h,
+ const char *caption)
+{
+ return NULL;
+}
+
+#endif /* HAVE_LIBX11 */
diff --git a/libs/input/GP_InputDriverX11.c b/libs/input/GP_InputDriverX11.c
new file mode 100644
index 0000000..d3b21c1
--- /dev/null
+++ b/libs/input/GP_InputDriverX11.c
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "../../config.h"
+
+#include "core/GP_Debug.h"
+#include "GP_Event.h"
+#include "GP_InputDriverX11.h"
+
+#ifdef HAVE_LIBX11
+
+/* X11 keycodes */
+static uint16_t keycode_table[] = {
+ GP_KEY_ESC, GP_KEY_1, GP_KEY_2, GP_KEY_3,
+ GP_KEY_4, GP_KEY_5, GP_KEY_6, GP_KEY_7,
+ GP_KEY_8, GP_KEY_9, GP_KEY_0, GP_KEY_MINUS,
+ GP_KEY_EQUAL, GP_KEY_BACKSPACE, GP_KEY_TAB, GP_KEY_Q,
+ GP_KEY_W, GP_KEY_E, GP_KEY_R, GP_KEY_T,
+ GP_KEY_Y, GP_KEY_U, GP_KEY_I, GP_KEY_O,
+ GP_KEY_P, GP_KEY_LEFT_BRACE, GP_KEY_RIGHT_BRACE, GP_KEY_ENTER,
+ GP_KEY_LEFT_CTRL, GP_KEY_A, GP_KEY_S, GP_KEY_D,
+ GP_KEY_F, GP_KEY_G, GP_KEY_H, GP_KEY_J,
+ GP_KEY_K, GP_KEY_L, GP_KEY_SEMICOLON, GP_KEY_APOSTROPHE,
+ 0, GP_KEY_LEFT_SHIFT, GP_KEY_BACKSLASH, GP_KEY_Z,
+ GP_KEY_X, GP_KEY_C, GP_KEY_V, GP_KEY_B,
+ GP_KEY_N, GP_KEY_M, GP_KEY_COMMA, GP_KEY_DOT,
+ GP_KEY_SLASH, GP_KEY_RIGHT_SHIFT, 0, GP_KEY_LEFT_ALT,
+ GP_KEY_SPACE, GP_KEY_CAPS_LOCK, GP_KEY_F1, GP_KEY_F2,
+ GP_KEY_F3, GP_KEY_F4, GP_KEY_F5, GP_KEY_F6,
+ GP_KEY_F7, GP_KEY_F8, GP_KEY_F9, GP_KEY_F10,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, GP_KEY_F11, GP_KEY_F12,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ GP_KEY_RIGHT_CTRL, 0, /* PRINTSCREEN */0, GP_KEY_RIGHT_ALT,
+ 0, GP_KEY_HOME, GP_KEY_UP, GP_KEY_PAGE_UP,
+ GP_KEY_LEFT, GP_KEY_RIGHT, GP_KEY_END, GP_KEY_DOWN,
+ GP_KEY_PAGE_DOWN, 0, GP_KEY_DELETE,
+};
+
+static const uint16_t keycode_table_size = sizeof(keycode_table)/2;
+
+void GP_InputDriverX11EventPut(XEvent *ev)
+{
+ int key = 0, keycode, press = 0;
+
+ switch (ev->type) {
+ /*
+ case SDL_MOUSEMOTION:
+ GP_EventPushRel(ev->motion.xrel, ev->motion.yrel, NULL);
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ switch (ev->button.button) {
+ case 1:
+ key = GP_BTN_LEFT;
+ break;
+ case 2:
+ key = GP_BTN_MIDDLE;
+ break;
+ case 3:
+ key = GP_BTN_RIGHT;
+ break;
+ default:
+ return;
+ }
+
+ GP_EventPush(GP_EV_KEY, key, ev->button.state, NULL);
+ break;
+ */
+ case KeyPress:
+ press = 1;
+ case KeyRelease:
+ keycode = ev->xkey.keycode;
+
+ if (keycode > 8 && keycode - 9 <= keycode_table_size)
+ key = keycode_table[keycode - 9];
+
+ if (key == 0) {
+ GP_DEBUG(0, "Unmapped X11 keycode %02x", keycode);
+ return;
+ }
+
+ GP_DEBUG(0, "Mapped X11 keycode %02x", keycode);
+ GP_EventPushKey(key, press, NULL);
+ break;
+ }
+}
+
+#endif /* HAVE_LIBX11 */
-----------------------------------------------------------------------
Summary of changes:
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.")