Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
13 Jun '14
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 e0193a071feaf04b54c65348bf11db0d8db6c4ac (commit)
via f701094e0e12d08c7f236d086f21887385240097 (commit)
via dc0555059702ca7ce621ebda8c8aa934da6aadd2 (commit)
via 5465a3982ed5266489faac926e1eb6f3288fdb35 (commit)
via 0ae6c2fe86b9fb25483cfd7389096912441a3400 (commit)
from f41246cb1b727024fe62f46daceefc3e810e330a (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/e0193a071feaf04b54c65348bf11db0d8db6…
commit e0193a071feaf04b54c65348bf11db0d8db6c4ac
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 23:38:58 2014 +0200
loaders: Rename Match functions + constify + doc
* Rename MatchExtension to LoaderByFilename
and MatchSignature to LoaderBySignature
* Constify GP_Loader arguments where possible
* Update loaders docs
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt
index 20b54d9d..bb834f97 100644
--- a/build/syms/Loaders_symbols.txt
+++ b/build/syms/Loaders_symbols.txt
@@ -81,8 +81,9 @@ GP_PSD
GP_SaveTmpFile
GP_LoadTmpFile
-GP_MatchSignature
-GP_MatchExtension
+GP_LoaderBySignature
+GP_LoaderByFilename
+GP_LoaderLoadImage
GP_ReadImage
GP_LoadImage
GP_SaveImage
diff --git a/demos/spiv/image_list.c b/demos/spiv/image_list.c
index 9d7a3ff4..be6532c0 100644
--- a/demos/spiv/image_list.c
+++ b/demos/spiv/image_list.c
@@ -69,7 +69,7 @@ static int dir_filter(const struct dirent *d)
//TODO: filter out directories
- if (GP_MatchExtension(d->d_name) == NULL)
+ if (!GP_LoaderByFilename(d->d_name))
return 0;
GP_DEBUG(4, "Adding file '%s'", d->d_name);
diff --git a/doc/loaders.txt b/doc/loaders.txt
index c1d94e8e..0b83df55 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -36,7 +36,7 @@ returned.
'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
+| 'ENOSYS' if GFXprim wasn't compiled with particular format support
| 'ENOMEM' if returned by 'malloc()'
| 'EIO', 'EINVAL' invalid image data (wrong signature, wrong or too short
header or image data)
@@ -110,12 +110,12 @@ Advanced Interface
-------------------------------------------------------------------------------
typedef struct GP_Loader {
/*
- * Loads an image.
+ * Reads an image from an IO stream.
*
- * Returns allocated and initialized bitmap on success, NULL on failure
- * and errno must be set.
+ * Returns newly allocated context cotaining the loaded image or in
+ * case of failure NULL and errno is set.
*/
- GP_Context *(*Load)(const char *src_path, GP_ProgressCallback *callback);
+ GP_Context *(*Read)(GP_IO *io, GP_ProgressCallback *callback);
/*
* Save an image.
@@ -126,6 +126,14 @@ typedef struct GP_Loader {
GP_ProgressCallback *callback);
/*
+ * GP_PIXEL_UNKNOWN terminated array of formats loader supports for save.
+ *
+ * This is _NOT_ a complete list loaders is able to save, due to automatic
+ * conversions (i.e. RGB888 vs BRG888).
+ */
+ const GP_PixelType *save_ptypes;
+
+ /*
* The buffer is filled with 32 bytes from an image start, returns 1 if
* image signature was found zero otherwise.
*/
@@ -136,49 +144,49 @@ typedef struct GP_Loader {
*/
const char *fmt_name;
- /* don't touch */
- struct GP_Loader *next;
-
/*
* NULL terminated array of file extensions.
*/
const char *extensions[];
} GP_Loader;
-
-/*
- * List loaders into the stdout.
- */
-void GP_ListLoaders(void);
-
-/*
- * Register a loader.
- */
-void GP_LoaderRegister(GP_Loader *self);
-
-/*
- * Unregister loader.
- */
-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 'Read', '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
-used to implement functions such as 'GP_LoadImage()'.
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_Loader.h>
+/* or */
+#include <GP.h>
+
+void GP_ListLoaders(void);
-You can print currently active loaders via the 'GP_ListLoaders()'. Register and
-unregister your own loaders by 'GP_LoaderRegister()' and
-'GP_LoaderUnregister()'. Once image loader is registered the generic loading
-functions can use it to load and save images.
+int GP_LoaderRegister(const GP_Loader *self);
+
+void GP_LoaderUnregister(const GP_Loader *self);
+-------------------------------------------------------------------------------
+
+The 'GP_ListLoaders()' function prints all currently registered loaders and
+their capabilities into the stdout.
+
+You can register and unregister your own loader by 'GP_LoaderRegister()' and
+'GP_LoaderUnregister()'. Once image loader is registered it's automatically
+used by all loaders functions.
+
+The 'GP_LoaderRegister()' can fail (return non-zero) if you try to register
+loader that is allready registered or if the loaders table is full (the table
+size is compile time constant and there should be space for at least fifty
+user defined loaders). I this cases the errno would be set to 'EEXIST' or
+'ENOSPC' respectively.
TIP: For example usage see image loader registration
link:example_loader_registration.html[example].
@@ -189,7 +197,7 @@ link:example_loader_registration.html[example].
/* or */
#include <GP.h>
-const GP_Loader *GP_MatchSignature(const void *buf)
+const GP_Loader *GP_LoaderBySignature(const void *buf)
-------------------------------------------------------------------------------
Returns pointer to image loader accordingly to image signature or NULL if no
@@ -202,15 +210,30 @@ bytes long.
/* or */
#include <GP.h>
-const GP_Loader *GP_MatchExtension(const char *path)
+const GP_Loader *GP_LoaderByFilename(const char *path)
-------------------------------------------------------------------------------
Matches loader by the file extension. This function does not check that the
-file exists or that it could be opened it only looks at the extension (i.e.
-string after the dot) and matches it against known extensions.
+file exists or that it could be opened etc. It only looks at the file
+extension (i.e. string at the end of the path after a dot) and matches it
+against extensions defined by loaders.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_Loader.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Loads an image given a loader structure.
+
+Returns NULL and sets errno to 'ENOSYS' loader 'Read()' callback is NULL.
-WARNING: If you attempt to modify the content of the structure the behavior is
- undefined. Most likely the program will crash.
+Otherwise prepares a link:loaders_io.html[GP_IO] from the 'src_path' file,
+calls the 'Read()' callbacks and closes the 'IO' before the call returns.
[[PNG]]
PNG Loader
diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h
index 5277fb41..90aeebb7 100644
--- a/include/loaders/GP_Loader.h
+++ b/include/loaders/GP_Loader.h
@@ -120,19 +120,20 @@ typedef struct GP_Loader {
* Takes pointer to buffer at least 32 bytes long and returns a pointer to
* matched loader or NULL.
*/
-const GP_Loader *GP_MatchSignature(const void *buf);
+const GP_Loader *GP_LoaderBySignature(const void *buf);
/*
- * Tries to match loader by extension. Returns NULL if no loader was found.
+ * Tries to match loader by filename extension. Returns NULL if no loader was
+ * found.
*/
-const GP_Loader *GP_MatchExtension(const char *path);
+const GP_Loader *GP_LoaderByFilename(const char *path);
/*
* Registers additional loader.
*
* Returns zero on success, non-zero if table of loaders was is full.
*/
-int GP_LoaderRegister(GP_Loader *self);
+int GP_LoaderRegister(const GP_Loader *self);
/*
* Unregisters a loader.
@@ -141,7 +142,7 @@ int GP_LoaderRegister(GP_Loader *self);
*
* You can unregister them using this function if you want.
*/
-void GP_LoaderUnregister(GP_Loader *self);
+void GP_LoaderUnregister(const GP_Loader *self);
/*
* Generic LoadImage for a given loader.
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index aa8911b2..12ca2fc8 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -41,7 +41,7 @@
#define MAX_LOADERS 64
-static GP_Loader *loaders[MAX_LOADERS] = {
+static const GP_Loader *loaders[MAX_LOADERS] = {
&GP_JPG,
&GP_PNG,
&GP_TIFF,
@@ -69,7 +69,7 @@ static unsigned int get_last_loader(void)
return i - 1;
}
-int GP_LoaderRegister(GP_Loader *self)
+int GP_LoaderRegister(const GP_Loader *self)
{
unsigned int i;
@@ -99,7 +99,7 @@ int GP_LoaderRegister(GP_Loader *self)
return 0;
}
-void GP_LoaderUnregister(GP_Loader *self)
+void GP_LoaderUnregister(const GP_Loader *self)
{
unsigned int i, last = get_last_loader();
@@ -146,7 +146,7 @@ void GP_ListLoaders(void)
}
}
-static struct GP_Loader *loader_by_extension(const char *ext)
+static const GP_Loader *loader_by_extension(const char *ext)
{
unsigned int i, j;
@@ -178,7 +178,7 @@ static const char *get_ext(const char *path)
return path + i + 1;
}
-static struct GP_Loader *loader_by_filename(const char *path)
+const GP_Loader *GP_LoaderByFilename(const char *path)
{
const char *ext = get_ext(path);
@@ -216,7 +216,7 @@ static const GP_Loader *loader_by_signature(const char *path)
fclose(f);
- ret = GP_MatchSignature(buf);
+ ret = GP_LoaderBySignature(buf);
if (ret == NULL)
errno = ENOSYS;
@@ -254,7 +254,7 @@ GP_Context *GP_ReadImage(GP_IO *io, GP_ProgressCallback *callback)
return NULL;
}
- loader = GP_MatchSignature(buf);
+ loader = GP_LoaderBySignature(buf);
if (!loader) {
GP_DEBUG(1, "Failed to find a loader by signature for"
@@ -325,7 +325,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
GP_Context *img;
const GP_Loader *ext_load = NULL, *sig_load;
- ext_load = loader_by_filename(src_path);
+ ext_load = GP_LoaderByFilename(src_path);
if (ext_load) {
img = GP_LoaderLoadImage(ext_load, src_path, callback);
@@ -387,7 +387,7 @@ out:
int GP_SaveImage(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
- struct GP_Loader *l = loader_by_filename(dst_path);
+ const GP_Loader *l = GP_LoaderByFilename(dst_path);
if (l == NULL) {
errno = EINVAL;
@@ -401,7 +401,7 @@ int GP_SaveImage(const GP_Context *src, const char *dst_path,
return 1;
}
-const GP_Loader *GP_MatchSignature(const void *buf)
+const GP_Loader *GP_LoaderBySignature(const void *buf)
{
unsigned int i;
@@ -416,8 +416,3 @@ const GP_Loader *GP_MatchSignature(const void *buf)
return NULL;
}
-
-const GP_Loader *GP_MatchExtension(const char *path)
-{
- return loader_by_filename(path);
-}
diff --git a/tests/loaders/Loader.c b/tests/loaders/Loader.c
index 4494825e..dcc9b921 100644
--- a/tests/loaders/Loader.c
+++ b/tests/loaders/Loader.c
@@ -117,7 +117,7 @@ static int loader_by_extension(void)
return TST_FAILED;
}
- loader = GP_MatchExtension("file.jpg");
+ loader = GP_LoaderByFilename("file.jpg");
if (loader != &GP_JPG) {
tst_msg("Failed to get JPEG loader");
@@ -126,7 +126,7 @@ static int loader_by_extension(void)
tst_msg("Succeded to get JPEG loader");
}
- loader = GP_MatchExtension("file.test");
+ loader = GP_LoaderByFilename("file.test");
if (loader != &test_loader) {
tst_msg("Failed to get registered TEST loader");
@@ -155,7 +155,7 @@ const struct tst_suite tst_suite = {
.tst_fn = register_loader_twice,
.flags = TST_CHECK_MALLOC},
- {.name = "MatchExtension()",
+ {.name = "LoaderByFilename()",
.tst_fn = loader_by_extension,
.flags = TST_CHECK_MALLOC},
http://repo.or.cz/w/gfxprim.git/commit/f701094e0e12d08c7f236d086f2188738524…
commit f701094e0e12d08c7f236d086f21887385240097
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 23:28:32 2014 +0200
loaders; GP_Loader: Fix typo in loaders table.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index 442a8329..aa8911b2 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -48,7 +48,7 @@ static GP_Loader *loaders[MAX_LOADERS] = {
&GP_GIF,
&GP_BMP,
&GP_PBM,
- &GP_PNM,
+ &GP_PGM,
&GP_PPM,
&GP_PNM,
&GP_JP2,
http://repo.or.cz/w/gfxprim.git/commit/dc0555059702ca7ce621ebda8c8aa934da6a…
commit dc0555059702ca7ce621ebda8c8aa934da6aadd2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 23:22:38 2014 +0200
loaders: Add save_ptypes to GP_Loader structure
Add save_ptypes, an array of pixel types supported by the Loader's
Save() method.
Note that these arrays does _NOT_ describe all formats that could be
saved by the loader because most of the loaders use LineConvert() for
trivial conversions (i.e. RGB888 to BRG888 to xRGB888 etc.)
Convinient interface to query if particular pixel type coud be saved by
particular loader will be added later.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/c_simple/loaders_register.c b/demos/c_simple/loaders_register.c
index 246394a5..4c596c40 100644
--- a/demos/c_simple/loaders_register.c
+++ b/demos/c_simple/loaders_register.c
@@ -90,8 +90,14 @@ static int save(const GP_Context *img, const char *dst_path,
return 0;
}
+static GP_PixelType save_ptypes[] = {
+ GP_PIXEL_G2,
+ GP_PIXEL_UNKNOWN,
+};
+
GP_Loader loader = {
.Save = save,
+ .save_ptypes = save_ptypes,
.fmt_name = "ASCII Art",
.extensions = {"txt", NULL},
};
diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h
index 6f07d2ea..5277fb41 100644
--- a/include/loaders/GP_Loader.h
+++ b/include/loaders/GP_Loader.h
@@ -92,6 +92,14 @@ typedef struct GP_Loader {
int (*Save)(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback);
/*
+ * GP_PIXEL_UNKNOWN terminated array of formats loader supports for save.
+ *
+ * This is _NOT_ a complete list loaders is able to save, due to automatic
+ * conversions (i.e. RGB888 vs BRG888).
+ */
+ const GP_PixelType *save_ptypes;
+
+ /*
* The buffer is filled with 32 bytes from an image start, returns 1 if
* image signature was found zero otherwise.
*/
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index 4313e2de..2d042bf2 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -895,6 +895,7 @@ int GP_SaveBMP(const GP_Context *src, const char *dst_path,
struct GP_Loader GP_BMP = {
.Read = GP_ReadBMP,
.Save = GP_SaveBMP,
+ .save_ptypes = out_pixel_types,
.Match = GP_MatchBMP,
.fmt_name = "BMP",
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index ea891712..dfca66fa 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -577,6 +577,7 @@ struct GP_Loader GP_JPG = {
#ifdef HAVE_JPEG
.Read = GP_ReadJPG,
.Save = GP_SaveJPG,
+ .save_ptypes = out_pixel_types,
#endif
.Match = GP_MatchJPG,
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index 763e819b..442a8329 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -127,9 +127,17 @@ void GP_ListLoaders(void)
printf("Format: %sn", loaders[i]->fmt_name);
printf("Read:t%sn", loaders[i]->Read ? "Yes" : "No");
printf("Save:t%sn", loaders[i]->Save ? "Yes" : "No");
+ if (loaders[i]->save_ptypes) {
+ printf("Saves Pixel Types: ");
+ for (j = 0; loaders[i]->save_ptypes[j]; j++) {
+ GP_PixelType ptype = loaders[i]->save_ptypes[j];
+ printf("%s ", GP_PixelTypeName(ptype));
+ }
+ printf("n");
+ }
printf("Match:t%sn", loaders[i]->Match ? "Yes" : "No");
printf("Extensions: ");
- for (j = 0; loaders[i]->extensions[j] != NULL; j++)
+ for (j = 0; loaders[i]->extensions[j]; j++)
printf("%s ", loaders[i]->extensions[j]);
printf("n");
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 1a73c9a8..deabf9ab 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -386,6 +386,20 @@ int GP_LoadPNGMetaData(const char *src_path, GP_MetaData *data)
return ret;
}
+static GP_PixelType save_ptypes[] = {
+ GP_PIXEL_BGR888,
+ GP_PIXEL_RGB888,
+ GP_PIXEL_G1,
+ GP_PIXEL_G2,
+ GP_PIXEL_G4,
+ GP_PIXEL_G8,
+#ifdef GP_PIXEL_G16
+ GP_PIXEL_G16,
+#endif
+ GP_PIXEL_RGBA8888,
+ GP_PIXEL_UNKNOWN,
+};
+
/*
* Maps gfxprim Pixel Type to the PNG format
*/
@@ -637,6 +651,7 @@ GP_Loader GP_PNG = {
#ifdef HAVE_LIBPNG
.Read = GP_ReadPNG,
.Save = GP_SavePNG,
+ .save_ptypes = save_ptypes,
#endif
.Match = GP_MatchPNG,
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 93bc1b68..ba459183 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -712,6 +712,11 @@ GP_Context *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback)
return read_bitmap(&buf, &header, callback);
}
+static GP_PixelType pbm_save_pixels[] = {
+ GP_PIXEL_G1,
+ GP_PIXEL_UNKNOWN,
+};
+
int GP_SavePBM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -879,6 +884,14 @@ static int pixel_to_depth(GP_Pixel pixel)
}
}
+static GP_PixelType pgm_save_pixels[] = {
+ GP_PIXEL_G1,
+ GP_PIXEL_G2,
+ GP_PIXEL_G4,
+ GP_PIXEL_G8,
+ GP_PIXEL_UNKNOWN,
+};
+
int GP_SavePGM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -1131,6 +1144,15 @@ GP_Context *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback)
return ret;
}
+static GP_PixelType pnm_save_pixels[] = {
+ GP_PIXEL_G1,
+ GP_PIXEL_G2,
+ GP_PIXEL_G4,
+ GP_PIXEL_G8,
+ GP_PIXEL_RGB888,
+ GP_PIXEL_UNKNOWN,
+};
+
int GP_SavePNM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -1174,6 +1196,7 @@ GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback)
struct GP_Loader GP_PBM = {
.Read = GP_ReadPBM,
.Save = GP_SavePBM,
+ .save_ptypes = pbm_save_pixels,
.Match = GP_MatchPBM,
.fmt_name = "Netpbm portable Bitmap",
@@ -1183,6 +1206,7 @@ struct GP_Loader GP_PBM = {
struct GP_Loader GP_PGM = {
.Read = GP_ReadPGM,
.Save = GP_SavePGM,
+ .save_ptypes = pgm_save_pixels,
.Match = GP_MatchPGM,
.fmt_name = "Netpbm portable Graymap",
@@ -1192,6 +1216,7 @@ struct GP_Loader GP_PGM = {
struct GP_Loader GP_PPM = {
.Read = GP_ReadPPM,
.Save = GP_SavePPM,
+ .save_ptypes = ppm_save_pixels,
.Match = GP_MatchPPM,
.fmt_name = "Netpbm portable Pixmap",
@@ -1201,6 +1226,7 @@ struct GP_Loader GP_PPM = {
struct GP_Loader GP_PNM = {
.Read = GP_ReadPNM,
.Save = GP_SavePNM,
+ .save_ptypes = pnm_save_pixels,
/*
* Avoid double Match
* This format is covered by PBM, PGM and PPM
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index bcc23b21..400d6734 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -632,6 +632,17 @@ static int save_rgb(TIFF *tiff, const GP_Context *src,
return 0;
}
+static GP_PixelType save_ptypes[] = {
+ GP_PIXEL_BGR888,
+ GP_PIXEL_RGB888,
+ GP_PIXEL_xRGB8888,
+ GP_PIXEL_G1,
+ GP_PIXEL_G2,
+ GP_PIXEL_G4,
+ GP_PIXEL_G8,
+ GP_PIXEL_UNKNOWN,
+};
+
int GP_SaveTIFF(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -746,6 +757,7 @@ struct GP_Loader GP_TIFF = {
#ifdef HAVE_TIFF
.Read = GP_ReadTIFF,
.Save = GP_SaveTIFF,
+ .save_ptypes = save_ptypes,
#endif
.Match = GP_MatchTIFF,
http://repo.or.cz/w/gfxprim.git/commit/5465a3982ed5266489faac926e1eb6f3288f…
commit 5465a3982ed5266489faac926e1eb6f3288fdb35
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 14:51:51 2014 +0200
core: include: Fix non-linux compatibility ifdefs
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_ByteOrder.h b/include/core/GP_ByteOrder.h
index f756d45a..7fac23a8 100644
--- a/include/core/GP_ByteOrder.h
+++ b/include/core/GP_ByteOrder.h
@@ -30,6 +30,9 @@
# include <endian.h>
#else /* BSD Family */
# include <machine/endian.h>
+# define __BYTE_ORDER _BYTE_ORDER
+# define __BIG_ENDIAN _BIG_ENDIAN
+# define __LITTLE_ENDIAN _LITTLE_ENDIAN
#endif
#endif /* CORE_GP_BYTE_ORDER_H */
diff --git a/include/core/GP_TempAlloc.h b/include/core/GP_TempAlloc.h
index 925b112e..e17adffb 100644
--- a/include/core/GP_TempAlloc.h
+++ b/include/core/GP_TempAlloc.h
@@ -47,7 +47,9 @@
#ifndef CORE_GP_TEMP_ALLOC_H
#define CORE_GP_TEMP_ALLOC_H
-#include <alloca.h>
+#ifdef __linux__
+# include <alloca.h>
+#endif
#include <stdlib.h>
#include "core/GP_Common.h"
http://repo.or.cz/w/gfxprim.git/commit/0ae6c2fe86b9fb25483cfd7389096912441a…
commit 0ae6c2fe86b9fb25483cfd7389096912441a3400
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 14:47:55 2014 +0200
demos, tests: Use /bin/sh instead of /bin/bash
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/bogoman/runtest.sh b/demos/bogoman/runtest.sh
index 07947072..dac7bc8b 100755
--- a/demos/bogoman/runtest.sh
+++ b/demos/bogoman/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Run dynamically linked test.
#
diff --git a/demos/c_simple/runtest.sh b/demos/c_simple/runtest.sh
index 07947072..dac7bc8b 100755
--- a/demos/c_simple/runtest.sh
+++ b/demos/c_simple/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Run dynamically linked test.
#
diff --git a/demos/grinder/runtest.sh b/demos/grinder/runtest.sh
index 163c76c4..eed2e0e5 100755
--- a/demos/grinder/runtest.sh
+++ b/demos/grinder/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Run dynamically linked test.
#
diff --git a/demos/particle/runtest.sh b/demos/particle/runtest.sh
index 07947072..dac7bc8b 100755
--- a/demos/particle/runtest.sh
+++ b/demos/particle/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Run dynamically linked test.
#
diff --git a/demos/py_simple/runpytest.sh b/demos/py_simple/runpytest.sh
index 264af15a..9afbb927 100755
--- a/demos/py_simple/runpytest.sh
+++ b/demos/py_simple/runpytest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Run python test with dynamically linked libGP.
#
diff --git a/demos/spiv/runtest.sh b/demos/spiv/runtest.sh
index 07947072..dac7bc8b 100755
--- a/demos/spiv/runtest.sh
+++ b/demos/spiv/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Run dynamically linked test.
#
diff --git a/demos/ttf2img/runtest.sh b/demos/ttf2img/runtest.sh
index 07947072..dac7bc8b 100755
--- a/demos/ttf2img/runtest.sh
+++ b/demos/ttf2img/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Run dynamically linked test.
#
diff --git a/tests/drivers/runtest.sh b/tests/drivers/runtest.sh
index ff2a001d..fc29b596 100755
--- a/tests/drivers/runtest.sh
+++ b/tests/drivers/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Run dynamically linked test.
#
-----------------------------------------------------------------------
Summary of changes:
build/syms/Loaders_symbols.txt | 5 +-
demos/bogoman/runtest.sh | 2 +-
demos/c_simple/loaders_register.c | 6 ++
demos/c_simple/runtest.sh | 2 +-
demos/grinder/runtest.sh | 2 +-
demos/particle/runtest.sh | 2 +-
demos/py_simple/runpytest.sh | 2 +-
demos/spiv/image_list.c | 2 +-
demos/spiv/runtest.sh | 2 +-
demos/ttf2img/runtest.sh | 2 +-
doc/loaders.txt | 97 +++++++++++++++++++++++--------------
include/core/GP_ByteOrder.h | 3 +
include/core/GP_TempAlloc.h | 4 +-
include/loaders/GP_Loader.h | 19 +++++--
libs/loaders/GP_BMP.c | 1 +
libs/loaders/GP_JPG.c | 1 +
libs/loaders/GP_Loader.c | 37 ++++++++-------
libs/loaders/GP_PNG.c | 15 ++++++
libs/loaders/GP_PNM.c | 26 ++++++++++
libs/loaders/GP_TIFF.c | 12 +++++
tests/drivers/runtest.sh | 2 +-
tests/loaders/Loader.c | 6 +-
22 files changed, 176 insertions(+), 74 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.")
1
0
13 Jun '14
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 14a68f948a63033de7c8d8dcf12978edb29b5fa2 (commit)
discards 069262b67e2bd246c98f76a4f9ddbbf9bf3c992f (commit)
via f41246cb1b727024fe62f46daceefc3e810e330a (commit)
via e30b2b00bee284d3e1b7f2055f278e023a950254 (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 (14a68f948a63033de7c8d8dcf12978edb29b5fa2)
N -- N -- N (f41246cb1b727024fe62f46daceefc3e810e330a)
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/f41246cb1b727024fe62f46daceefc3e810e…
commit f41246cb1b727024fe62f46daceefc3e810e330a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 11:40:39 2014 +0200
build: Fix Debian build, core should link with -lrt
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/Makefile b/build/Makefile
index 3053edfa..5f88872b 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -37,10 +37,10 @@ endif
$(DYNAMIC_LIB): $(LIB_OBJECTS)
ifdef VERBOSE
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm $(LDLIBS_core) -o $@
+ $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm -lrt $(LDLIBS_core) -o $@
else
@echo "LD $@"
- @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm $(LDLIBS_core) -o $@
+ @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm -lrt $(LDLIBS_core) -o $@
endif
$(SYMLINKS): $(DYNAMIC_LIB)
http://repo.or.cz/w/gfxprim.git/commit/e30b2b00bee284d3e1b7f2055f278e023a95…
commit e30b2b00bee284d3e1b7f2055f278e023a950254
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 11:32:22 2014 +0200
loaders: GP_Loader: Get rid of unneeded members
This commit cleanups a few aspects of loaders implementation.
It creates GP_LoaderLoadImage() function that can be used to load
image from path for a given loader pointer which allows us to.
* Get rid of the Load() callback from GP_Loader
* Unify GP_LoadFOO implementation
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/c_simple/loaders_register.c b/demos/c_simple/loaders_register.c
index 4b36461a..246394a5 100644
--- a/demos/c_simple/loaders_register.c
+++ b/demos/c_simple/loaders_register.c
@@ -91,9 +91,7 @@ static int save(const GP_Context *img, const char *dst_path,
}
GP_Loader loader = {
- .Load = NULL,
.Save = save,
- .Match = NULL,
.fmt_name = "ASCII Art",
.extensions = {"txt", NULL},
};
diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h
index 3860ac10..6f07d2ea 100644
--- a/include/loaders/GP_Loader.h
+++ b/include/loaders/GP_Loader.h
@@ -85,13 +85,6 @@ typedef struct GP_Loader {
GP_Context *(*Read)(GP_IO *io, GP_ProgressCallback *callback);
/*
- * Loads an image from a file.
- *
- * TODO: Remove due to Read
- */
- GP_Context *(*Load)(const char *src_path, GP_ProgressCallback *callback);
-
- /*
* Save an image.
*
* Returns zero on succes, non-zero on failure and errno must be set.
@@ -109,9 +102,6 @@ typedef struct GP_Loader {
*/
const char *fmt_name;
- /* don't touch */
- struct GP_Loader *next;
-
/*
* NULL terminated array of file extensions.
*/
@@ -146,6 +136,15 @@ int GP_LoaderRegister(GP_Loader *self);
void GP_LoaderUnregister(GP_Loader *self);
/*
+ * Generic LoadImage for a given loader.
+ *
+ * The function prepares the IO from file, calls the loader Read() method,
+ * closes the IO and returns the context.
+ */
+GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path,
+ GP_ProgressCallback *callback);
+
+/*
* List loaders into the stdout
*/
void GP_ListLoaders(void);
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index 9fcff422..4313e2de 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -703,21 +703,7 @@ err1:
GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback)
{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadBMP(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
+ return GP_LoaderLoadImage(&GP_BMP, src_path, callback);
}
/*
@@ -908,7 +894,6 @@ int GP_SaveBMP(const GP_Context *src, const char *dst_path,
struct GP_Loader GP_BMP = {
.Read = GP_ReadBMP,
- .Load = GP_LoadBMP,
.Save = GP_SaveBMP,
.Match = GP_MatchBMP,
diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c
index 6425d60a..a4f3afc0 100644
--- a/libs/loaders/GP_GIF.c
+++ b/libs/loaders/GP_GIF.c
@@ -358,25 +358,6 @@ err1:
return NULL;
}
-GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadGIF(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
#else
int GP_MatchGIF(const void GP_UNUSED(*buf))
@@ -392,20 +373,19 @@ GP_Context *GP_ReadGIF(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadGIF(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
+#endif /* HAVE_GIFLIB */
+
+GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback)
{
- errno = ENOSYS;
- return NULL;
+ return GP_LoaderLoadImage(&GP_GIF, src_path, callback);
}
-#endif /* HAVE_GIFLIB */
-
struct GP_Loader GP_GIF = {
+#ifdef HAVE_GIFLIB
.Read = GP_ReadGIF,
- .Load = GP_LoadGIF,
- .Save = NULL,
+#endif
.Match = GP_MatchGIF,
+
.fmt_name = "Graphics Interchange Format",
.extensions = {"gif", NULL},
};
diff --git a/libs/loaders/GP_JP2.c b/libs/loaders/GP_JP2.c
index f451b6f1..941849b2 100644
--- a/libs/loaders/GP_JP2.c
+++ b/libs/loaders/GP_JP2.c
@@ -225,25 +225,6 @@ err0:
return res;
}
-GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadJP2(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
#else
GP_Context *GP_ReadJP2(GP_IO GP_UNUSED(*io),
@@ -253,19 +234,17 @@ GP_Context *GP_ReadJP2(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadJP2(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
+#endif /* HAVE_OPENJPEG */
+
+GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback)
{
- errno = ENOSYS;
- return NULL;
+ return GP_LoaderLoadImage(&GP_JP2, src_path, callback);
}
-#endif /* HAVE_OPENJPEG */
-
struct GP_Loader GP_JP2 = {
+#ifdef HAVE_OPENJPEG
.Read = GP_ReadJP2,
- .Load = GP_LoadJP2,
- .Save = NULL,
+#endif
.Match = GP_MatchJP2,
.fmt_name = "JPEG 2000",
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index ca14b180..ea891712 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -290,25 +290,6 @@ err1:
return NULL;
}
-GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadJPG(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
#define JPEG_COM_MAX 128
static void read_jpg_metadata(struct jpeg_decompress_struct *cinfo,
@@ -564,13 +545,6 @@ GP_Context *GP_ReadJPG(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadJPG(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
-{
- errno = ENOSYS;
- return NULL;
-}
-
int GP_ReadJPGMetaData(GP_IO GP_UNUSED(*io), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
@@ -594,10 +568,16 @@ int GP_SaveJPG(const GP_Context GP_UNUSED(*src),
#endif /* HAVE_JPEG */
+GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_JPG, src_path, callback);
+}
+
struct GP_Loader GP_JPG = {
+#ifdef HAVE_JPEG
.Read = GP_ReadJPG,
- .Load = GP_LoadJPG,
.Save = GP_SaveJPG,
+#endif
.Match = GP_MatchJPG,
.fmt_name = "JPEG",
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index c3b74feb..763e819b 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -126,7 +126,6 @@ void GP_ListLoaders(void)
for (i = 0; loaders[i]; i++) {
printf("Format: %sn", loaders[i]->fmt_name);
printf("Read:t%sn", loaders[i]->Read ? "Yes" : "No");
- printf("Load:t%sn", loaders[i]->Load ? "Yes" : "No");
printf("Save:t%sn", loaders[i]->Save ? "Yes" : "No");
printf("Match:t%sn", loaders[i]->Match ? "Yes" : "No");
printf("Extensions: ");
@@ -268,6 +267,31 @@ GP_Context *GP_ReadImage(GP_IO *io, GP_ProgressCallback *callback)
return loader->Read(io, callback);
}
+GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path,
+ GP_ProgressCallback *callback)
+{
+ GP_IO *io;
+ GP_Context *res;
+ int err;
+
+ if (!self->Read) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ io = GP_IOFile(src_path, GP_IO_RDONLY);
+ if (!io)
+ return NULL;
+
+ res = self->Read(io, callback);
+
+ err = errno;
+ GP_IOClose(io);
+ errno = err;
+
+ return res;
+}
+
GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
{
int err;
@@ -295,8 +319,8 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
ext_load = loader_by_filename(src_path);
- if (ext_load != NULL && ext_load->Load != NULL) {
- img = ext_load->Load(src_path, callback);
+ if (ext_load) {
+ img = GP_LoaderLoadImage(ext_load, src_path, callback);
if (img)
return img;
@@ -316,8 +340,8 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
src_path, ext_load->fmt_name, sig_load->fmt_name);
}
- if (sig_load && sig_load->Load != NULL)
- return sig_load->Load(src_path, callback);
+ if (sig_load)
+ return GP_LoaderLoadImage(sig_load, src_path, callback);
errno = ENOSYS;
return NULL;
diff --git a/libs/loaders/GP_PCX.c b/libs/loaders/GP_PCX.c
index b04dc41b..330b0a7f 100644
--- a/libs/loaders/GP_PCX.c
+++ b/libs/loaders/GP_PCX.c
@@ -549,27 +549,11 @@ err0:
GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback)
{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPCX(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
+ return GP_LoaderLoadImage(&GP_PCX, src_path, callback);
}
struct GP_Loader GP_PCX = {
.Read = GP_ReadPCX,
- .Load = GP_LoadPCX,
- .Save = NULL,
.Match = GP_MatchPCX,
.fmt_name = "ZSoft PCX",
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 2da8bcef..1a73c9a8 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -264,25 +264,6 @@ err1:
return NULL;
}
-GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPNG(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *data)
{
double gamma;
@@ -625,13 +606,6 @@ GP_Context *GP_ReadPNG(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadPNG(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
-{
- errno = ENOSYS;
- return NULL;
-}
-
int GP_ReadPNGMetaData(GP_IO GP_UNUSED(*io), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
@@ -654,10 +628,16 @@ int GP_SavePNG(const GP_Context GP_UNUSED(*src),
#endif /* HAVE_LIBPNG */
+GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PNG, src_path, callback);
+}
+
GP_Loader GP_PNG = {
+#ifdef HAVE_LIBPNG
.Read = GP_ReadPNG,
- .Load = GP_LoadPNG,
.Save = GP_SavePNG,
+#endif
.Match = GP_MatchPNG,
.fmt_name = "Portable Network Graphics",
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 63bb5361..93bc1b68 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -712,25 +712,6 @@ GP_Context *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback)
return read_bitmap(&buf, &header, callback);
}
-GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPBM(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
int GP_SavePBM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -882,25 +863,6 @@ GP_Context *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback)
return read_graymap(&buf, &header, callback);
}
-GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPGM(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
static int pixel_to_depth(GP_Pixel pixel)
{
switch (pixel) {
@@ -1026,25 +988,6 @@ GP_Context *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback)
return read_pixmap(&buf, &header, callback);
}
-GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPPM(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
static int write_binary_ppm(FILE *f, GP_Context *src)
{
uint32_t x, y;
@@ -1188,25 +1131,6 @@ GP_Context *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback)
return ret;
}
-GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPNM(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
int GP_SavePNM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -1227,9 +1151,28 @@ int GP_SavePNM(const GP_Context *src, const char *dst_path,
}
}
+GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PBM, src_path, callback);
+}
+
+GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PGM, src_path, callback);
+}
+
+GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PPM, src_path, callback);
+}
+
+GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PNM, src_path, callback);
+}
+
struct GP_Loader GP_PBM = {
.Read = GP_ReadPBM,
- .Load = GP_LoadPBM,
.Save = GP_SavePBM,
.Match = GP_MatchPBM,
@@ -1239,7 +1182,6 @@ struct GP_Loader GP_PBM = {
struct GP_Loader GP_PGM = {
.Read = GP_ReadPGM,
- .Load = GP_LoadPGM,
.Save = GP_SavePGM,
.Match = GP_MatchPGM,
@@ -1249,7 +1191,6 @@ struct GP_Loader GP_PGM = {
struct GP_Loader GP_PPM = {
.Read = GP_ReadPPM,
- .Load = GP_LoadPPM,
.Save = GP_SavePPM,
.Match = GP_MatchPPM,
@@ -1259,7 +1200,6 @@ struct GP_Loader GP_PPM = {
struct GP_Loader GP_PNM = {
.Read = GP_ReadPNM,
- .Load = GP_LoadPNM,
.Save = GP_SavePNM,
/*
* Avoid double Match
diff --git a/libs/loaders/GP_PSD.c b/libs/loaders/GP_PSD.c
index 5ef73f11..ba86cb4e 100644
--- a/libs/loaders/GP_PSD.c
+++ b/libs/loaders/GP_PSD.c
@@ -813,27 +813,11 @@ err:
GP_Context *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback)
{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPSD(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
+ return GP_LoaderLoadImage(&GP_PSD, src_path, callback);
}
struct GP_Loader GP_PSD = {
.Read = GP_ReadPSD,
- .Load = GP_LoadPSD,
- .Save = NULL,
.Match = GP_MatchPSD,
.fmt_name = "Adobe Photoshop Image",
diff --git a/libs/loaders/GP_PSP.c b/libs/loaders/GP_PSP.c
index bacd4b9b..64cdeaa6 100644
--- a/libs/loaders/GP_PSP.c
+++ b/libs/loaders/GP_PSP.c
@@ -491,27 +491,11 @@ err0:
GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback)
{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPSP(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
+ return GP_LoaderLoadImage(&GP_PSP, src_path, callback);
}
struct GP_Loader GP_PSP = {
.Read = GP_ReadPSP,
- .Load = GP_LoadPSP,
- .Save = NULL,
.Match = GP_MatchPSP,
.fmt_name = "Paint Shop Pro Image",
.extensions = {"psp", "pspimage", NULL},
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index 1ea06554..bcc23b21 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -536,25 +536,6 @@ err0:
return NULL;
}
-GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadTIFF(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
static int save_grayscale(TIFF *tiff, const GP_Context *src,
GP_ProgressCallback *callback)
{
@@ -746,13 +727,6 @@ GP_Context *GP_ReadTIFF(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadTIFF(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
-{
- errno = ENOSYS;
- return NULL;
-}
-
int GP_SaveTIFF(const GP_Context GP_UNUSED(*src),
const char GP_UNUSED(*dst_path),
GP_ProgressCallback GP_UNUSED(*callback))
@@ -763,10 +737,16 @@ int GP_SaveTIFF(const GP_Context GP_UNUSED(*src),
#endif /* HAVE_TIFF */
+GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_TIFF, src_path, callback);
+}
+
struct GP_Loader GP_TIFF = {
+#ifdef HAVE_TIFF
.Read = GP_ReadTIFF,
- .Load = GP_LoadTIFF,
.Save = GP_SaveTIFF,
+#endif
.Match = GP_MatchTIFF,
.fmt_name = "Tag Image File Format",
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/loaders_register.c | 2 --
1 files changed, 0 insertions(+), 2 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.")
1
0
13 Jun '14
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 14a68f948a63033de7c8d8dcf12978edb29b5fa2 (commit)
from 069262b67e2bd246c98f76a4f9ddbbf9bf3c992f (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/14a68f948a63033de7c8d8dcf12978edb29b…
commit 14a68f948a63033de7c8d8dcf12978edb29b5fa2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 11:40:39 2014 +0200
build: Fix Debian build, core should link with -lrt
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/Makefile b/build/Makefile
index 3053edfa..5f88872b 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -37,10 +37,10 @@ endif
$(DYNAMIC_LIB): $(LIB_OBJECTS)
ifdef VERBOSE
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm $(LDLIBS_core) -o $@
+ $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm -lrt $(LDLIBS_core) -o $@
else
@echo "LD $@"
- @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm $(LDLIBS_core) -o $@
+ @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm -lrt $(LDLIBS_core) -o $@
endif
$(SYMLINKS): $(DYNAMIC_LIB)
-----------------------------------------------------------------------
Summary of changes:
build/Makefile | 4 ++--
1 files changed, 2 insertions(+), 2 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.")
1
0
13 Jun '14
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 069262b67e2bd246c98f76a4f9ddbbf9bf3c992f (commit)
via 2d816b6c01944b146c69c1db821eea6147e2b5cb (commit)
via 4bec01e5af42cb68e680f3a6d452d543b8c4d004 (commit)
via e341668ccad607f9843386e206105f086ae307d0 (commit)
from 13195186d44e871af057bda262ddf8467ff8049c (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/069262b67e2bd246c98f76a4f9ddbbf9bf3c…
commit 069262b67e2bd246c98f76a4f9ddbbf9bf3c992f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 11:32:22 2014 +0200
loaders: GP_Loader: Get rid of unneeded members
This commit cleanups a few aspects of loaders implementation.
It creates GP_LoaderLoadImage() function that can be used to load
image from path for a given loader pointer which allows us to.
* Get rid of the Load() callback from GP_Loader
* Unify GP_LoadFOO implementation
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h
index 3860ac10..6f07d2ea 100644
--- a/include/loaders/GP_Loader.h
+++ b/include/loaders/GP_Loader.h
@@ -85,13 +85,6 @@ typedef struct GP_Loader {
GP_Context *(*Read)(GP_IO *io, GP_ProgressCallback *callback);
/*
- * Loads an image from a file.
- *
- * TODO: Remove due to Read
- */
- GP_Context *(*Load)(const char *src_path, GP_ProgressCallback *callback);
-
- /*
* Save an image.
*
* Returns zero on succes, non-zero on failure and errno must be set.
@@ -109,9 +102,6 @@ typedef struct GP_Loader {
*/
const char *fmt_name;
- /* don't touch */
- struct GP_Loader *next;
-
/*
* NULL terminated array of file extensions.
*/
@@ -146,6 +136,15 @@ int GP_LoaderRegister(GP_Loader *self);
void GP_LoaderUnregister(GP_Loader *self);
/*
+ * Generic LoadImage for a given loader.
+ *
+ * The function prepares the IO from file, calls the loader Read() method,
+ * closes the IO and returns the context.
+ */
+GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path,
+ GP_ProgressCallback *callback);
+
+/*
* List loaders into the stdout
*/
void GP_ListLoaders(void);
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index 9fcff422..4313e2de 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -703,21 +703,7 @@ err1:
GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback)
{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadBMP(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
+ return GP_LoaderLoadImage(&GP_BMP, src_path, callback);
}
/*
@@ -908,7 +894,6 @@ int GP_SaveBMP(const GP_Context *src, const char *dst_path,
struct GP_Loader GP_BMP = {
.Read = GP_ReadBMP,
- .Load = GP_LoadBMP,
.Save = GP_SaveBMP,
.Match = GP_MatchBMP,
diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c
index 6425d60a..a4f3afc0 100644
--- a/libs/loaders/GP_GIF.c
+++ b/libs/loaders/GP_GIF.c
@@ -358,25 +358,6 @@ err1:
return NULL;
}
-GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadGIF(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
#else
int GP_MatchGIF(const void GP_UNUSED(*buf))
@@ -392,20 +373,19 @@ GP_Context *GP_ReadGIF(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadGIF(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
+#endif /* HAVE_GIFLIB */
+
+GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback)
{
- errno = ENOSYS;
- return NULL;
+ return GP_LoaderLoadImage(&GP_GIF, src_path, callback);
}
-#endif /* HAVE_GIFLIB */
-
struct GP_Loader GP_GIF = {
+#ifdef HAVE_GIFLIB
.Read = GP_ReadGIF,
- .Load = GP_LoadGIF,
- .Save = NULL,
+#endif
.Match = GP_MatchGIF,
+
.fmt_name = "Graphics Interchange Format",
.extensions = {"gif", NULL},
};
diff --git a/libs/loaders/GP_JP2.c b/libs/loaders/GP_JP2.c
index f451b6f1..941849b2 100644
--- a/libs/loaders/GP_JP2.c
+++ b/libs/loaders/GP_JP2.c
@@ -225,25 +225,6 @@ err0:
return res;
}
-GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadJP2(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
#else
GP_Context *GP_ReadJP2(GP_IO GP_UNUSED(*io),
@@ -253,19 +234,17 @@ GP_Context *GP_ReadJP2(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadJP2(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
+#endif /* HAVE_OPENJPEG */
+
+GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback)
{
- errno = ENOSYS;
- return NULL;
+ return GP_LoaderLoadImage(&GP_JP2, src_path, callback);
}
-#endif /* HAVE_OPENJPEG */
-
struct GP_Loader GP_JP2 = {
+#ifdef HAVE_OPENJPEG
.Read = GP_ReadJP2,
- .Load = GP_LoadJP2,
- .Save = NULL,
+#endif
.Match = GP_MatchJP2,
.fmt_name = "JPEG 2000",
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index ca14b180..ea891712 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -290,25 +290,6 @@ err1:
return NULL;
}
-GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadJPG(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
#define JPEG_COM_MAX 128
static void read_jpg_metadata(struct jpeg_decompress_struct *cinfo,
@@ -564,13 +545,6 @@ GP_Context *GP_ReadJPG(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadJPG(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
-{
- errno = ENOSYS;
- return NULL;
-}
-
int GP_ReadJPGMetaData(GP_IO GP_UNUSED(*io), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
@@ -594,10 +568,16 @@ int GP_SaveJPG(const GP_Context GP_UNUSED(*src),
#endif /* HAVE_JPEG */
+GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_JPG, src_path, callback);
+}
+
struct GP_Loader GP_JPG = {
+#ifdef HAVE_JPEG
.Read = GP_ReadJPG,
- .Load = GP_LoadJPG,
.Save = GP_SaveJPG,
+#endif
.Match = GP_MatchJPG,
.fmt_name = "JPEG",
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index c3b74feb..763e819b 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -126,7 +126,6 @@ void GP_ListLoaders(void)
for (i = 0; loaders[i]; i++) {
printf("Format: %sn", loaders[i]->fmt_name);
printf("Read:t%sn", loaders[i]->Read ? "Yes" : "No");
- printf("Load:t%sn", loaders[i]->Load ? "Yes" : "No");
printf("Save:t%sn", loaders[i]->Save ? "Yes" : "No");
printf("Match:t%sn", loaders[i]->Match ? "Yes" : "No");
printf("Extensions: ");
@@ -268,6 +267,31 @@ GP_Context *GP_ReadImage(GP_IO *io, GP_ProgressCallback *callback)
return loader->Read(io, callback);
}
+GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path,
+ GP_ProgressCallback *callback)
+{
+ GP_IO *io;
+ GP_Context *res;
+ int err;
+
+ if (!self->Read) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ io = GP_IOFile(src_path, GP_IO_RDONLY);
+ if (!io)
+ return NULL;
+
+ res = self->Read(io, callback);
+
+ err = errno;
+ GP_IOClose(io);
+ errno = err;
+
+ return res;
+}
+
GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
{
int err;
@@ -295,8 +319,8 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
ext_load = loader_by_filename(src_path);
- if (ext_load != NULL && ext_load->Load != NULL) {
- img = ext_load->Load(src_path, callback);
+ if (ext_load) {
+ img = GP_LoaderLoadImage(ext_load, src_path, callback);
if (img)
return img;
@@ -316,8 +340,8 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
src_path, ext_load->fmt_name, sig_load->fmt_name);
}
- if (sig_load && sig_load->Load != NULL)
- return sig_load->Load(src_path, callback);
+ if (sig_load)
+ return GP_LoaderLoadImage(sig_load, src_path, callback);
errno = ENOSYS;
return NULL;
diff --git a/libs/loaders/GP_PCX.c b/libs/loaders/GP_PCX.c
index b04dc41b..330b0a7f 100644
--- a/libs/loaders/GP_PCX.c
+++ b/libs/loaders/GP_PCX.c
@@ -549,27 +549,11 @@ err0:
GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback)
{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPCX(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
+ return GP_LoaderLoadImage(&GP_PCX, src_path, callback);
}
struct GP_Loader GP_PCX = {
.Read = GP_ReadPCX,
- .Load = GP_LoadPCX,
- .Save = NULL,
.Match = GP_MatchPCX,
.fmt_name = "ZSoft PCX",
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 2da8bcef..1a73c9a8 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -264,25 +264,6 @@ err1:
return NULL;
}
-GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPNG(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *data)
{
double gamma;
@@ -625,13 +606,6 @@ GP_Context *GP_ReadPNG(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadPNG(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
-{
- errno = ENOSYS;
- return NULL;
-}
-
int GP_ReadPNGMetaData(GP_IO GP_UNUSED(*io), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
@@ -654,10 +628,16 @@ int GP_SavePNG(const GP_Context GP_UNUSED(*src),
#endif /* HAVE_LIBPNG */
+GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PNG, src_path, callback);
+}
+
GP_Loader GP_PNG = {
+#ifdef HAVE_LIBPNG
.Read = GP_ReadPNG,
- .Load = GP_LoadPNG,
.Save = GP_SavePNG,
+#endif
.Match = GP_MatchPNG,
.fmt_name = "Portable Network Graphics",
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 63bb5361..93bc1b68 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -712,25 +712,6 @@ GP_Context *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback)
return read_bitmap(&buf, &header, callback);
}
-GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPBM(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
int GP_SavePBM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -882,25 +863,6 @@ GP_Context *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback)
return read_graymap(&buf, &header, callback);
}
-GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPGM(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
static int pixel_to_depth(GP_Pixel pixel)
{
switch (pixel) {
@@ -1026,25 +988,6 @@ GP_Context *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback)
return read_pixmap(&buf, &header, callback);
}
-GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPPM(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
static int write_binary_ppm(FILE *f, GP_Context *src)
{
uint32_t x, y;
@@ -1188,25 +1131,6 @@ GP_Context *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback)
return ret;
}
-GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPNM(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
int GP_SavePNM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -1227,9 +1151,28 @@ int GP_SavePNM(const GP_Context *src, const char *dst_path,
}
}
+GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PBM, src_path, callback);
+}
+
+GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PGM, src_path, callback);
+}
+
+GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PPM, src_path, callback);
+}
+
+GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_PNM, src_path, callback);
+}
+
struct GP_Loader GP_PBM = {
.Read = GP_ReadPBM,
- .Load = GP_LoadPBM,
.Save = GP_SavePBM,
.Match = GP_MatchPBM,
@@ -1239,7 +1182,6 @@ struct GP_Loader GP_PBM = {
struct GP_Loader GP_PGM = {
.Read = GP_ReadPGM,
- .Load = GP_LoadPGM,
.Save = GP_SavePGM,
.Match = GP_MatchPGM,
@@ -1249,7 +1191,6 @@ struct GP_Loader GP_PGM = {
struct GP_Loader GP_PPM = {
.Read = GP_ReadPPM,
- .Load = GP_LoadPPM,
.Save = GP_SavePPM,
.Match = GP_MatchPPM,
@@ -1259,7 +1200,6 @@ struct GP_Loader GP_PPM = {
struct GP_Loader GP_PNM = {
.Read = GP_ReadPNM,
- .Load = GP_LoadPNM,
.Save = GP_SavePNM,
/*
* Avoid double Match
diff --git a/libs/loaders/GP_PSD.c b/libs/loaders/GP_PSD.c
index 5ef73f11..ba86cb4e 100644
--- a/libs/loaders/GP_PSD.c
+++ b/libs/loaders/GP_PSD.c
@@ -813,27 +813,11 @@ err:
GP_Context *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback)
{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPSD(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
+ return GP_LoaderLoadImage(&GP_PSD, src_path, callback);
}
struct GP_Loader GP_PSD = {
.Read = GP_ReadPSD,
- .Load = GP_LoadPSD,
- .Save = NULL,
.Match = GP_MatchPSD,
.fmt_name = "Adobe Photoshop Image",
diff --git a/libs/loaders/GP_PSP.c b/libs/loaders/GP_PSP.c
index bacd4b9b..64cdeaa6 100644
--- a/libs/loaders/GP_PSP.c
+++ b/libs/loaders/GP_PSP.c
@@ -491,27 +491,11 @@ err0:
GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback)
{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadPSP(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
+ return GP_LoaderLoadImage(&GP_PSP, src_path, callback);
}
struct GP_Loader GP_PSP = {
.Read = GP_ReadPSP,
- .Load = GP_LoadPSP,
- .Save = NULL,
.Match = GP_MatchPSP,
.fmt_name = "Paint Shop Pro Image",
.extensions = {"psp", "pspimage", NULL},
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index 1ea06554..bcc23b21 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -536,25 +536,6 @@ err0:
return NULL;
}
-GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback)
-{
- GP_IO *io;
- GP_Context *res;
- int err;
-
- io = GP_IOFile(src_path, GP_IO_RDONLY);
- if (!io)
- return NULL;
-
- res = GP_ReadTIFF(io, callback);
-
- err = errno;
- GP_IOClose(io);
- errno = err;
-
- return res;
-}
-
static int save_grayscale(TIFF *tiff, const GP_Context *src,
GP_ProgressCallback *callback)
{
@@ -746,13 +727,6 @@ GP_Context *GP_ReadTIFF(GP_IO GP_UNUSED(*io),
return NULL;
}
-GP_Context *GP_LoadTIFF(const char GP_UNUSED(*src_path),
- GP_ProgressCallback GP_UNUSED(*callback))
-{
- errno = ENOSYS;
- return NULL;
-}
-
int GP_SaveTIFF(const GP_Context GP_UNUSED(*src),
const char GP_UNUSED(*dst_path),
GP_ProgressCallback GP_UNUSED(*callback))
@@ -763,10 +737,16 @@ int GP_SaveTIFF(const GP_Context GP_UNUSED(*src),
#endif /* HAVE_TIFF */
+GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback)
+{
+ return GP_LoaderLoadImage(&GP_TIFF, src_path, callback);
+}
+
struct GP_Loader GP_TIFF = {
+#ifdef HAVE_TIFF
.Read = GP_ReadTIFF,
- .Load = GP_LoadTIFF,
.Save = GP_SaveTIFF,
+#endif
.Match = GP_MatchTIFF,
.fmt_name = "Tag Image File Format",
http://repo.or.cz/w/gfxprim.git/commit/2d816b6c01944b146c69c1db821eea6147e2…
commit 2d816b6c01944b146c69c1db821eea6147e2b5cb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 00:47:44 2014 +0200
loaders: Move GP_Loader structures to loaders
This commit moves the GP_Loader structures from GP_Loader.c to
respecitive loaders which is preparation for additional members
that will be added to GP_Loader structure.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt
index b73506dd..20b54d9d 100644
--- a/build/syms/Loaders_symbols.txt
+++ b/build/syms/Loaders_symbols.txt
@@ -6,6 +6,7 @@ GP_LoadJPG
GP_SaveJPG
GP_ReadJPGMetaData
GP_LoadJPGMetaData
+GP_JPG
GP_MatchPNG
GP_ReadPNG
@@ -13,57 +14,69 @@ GP_LoadPNG
GP_ReadPNGMetaData
GP_LoadPNGMetaData
GP_SavePNG
+GP_PNG
GP_MatchBMP
GP_WriteBMP
GP_LoadBMP
GP_ReadBMP
GP_SaveBMP
+GP_BMP
GP_MatchPSP
GP_ReadPSP
GP_LoadPSP
+GP_PSP
GP_MatchGIF
GP_LoadGIF
GP_ReadGIF
+GP_GIF
GP_MatchTIFF
GP_ReadTIFF
GP_LoadTIFF
GP_SaveTIFF
+GP_TIFF
GP_ReadPBM
GP_LoadPBM
GP_SavePBM
GP_MatchPBM
+GP_PBM
GP_ReadPGM
GP_LoadPGM
GP_SavePGM
GP_MatchPGM
+GP_PGM
GP_ReadPPM
GP_LoadPPM
GP_SavePPM
GP_MatchPPM
+GP_PPM
GP_ReadPNM
GP_LoadPNM
GP_SavePNM
GP_MatchPNM
+GP_PNM
GP_ReadJP2
GP_LoadJP2
GP_MatchJP2
+GP_JP2
GP_ReadPCX
GP_LoadPCX
GP_MatchPCX
+GP_PCX
GP_ReadPSD
GP_LoadPSD
GP_MatchPSD
+GP_PSD
GP_SaveTmpFile
GP_LoadTmpFile
diff --git a/include/loaders/GP_BMP.h b/include/loaders/GP_BMP.h
index 047d7733..982de158 100644
--- a/include/loaders/GP_BMP.h
+++ b/include/loaders/GP_BMP.h
@@ -23,9 +23,7 @@
#ifndef LOADERS_GP_BMP_H
#define LOADERS_GP_BMP_H
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-#include "loaders/GP_IO.h"
+#include "loaders/GP_Loader.h"
/*
* Reads a BMP from an IO stream.
@@ -60,4 +58,7 @@ int GP_SaveBMP(const GP_Context *src, const char *dst_path,
*/
int GP_MatchBMP(const void *buf);
+
+extern GP_Loader GP_BMP;
+
#endif /* LOADERS_GP_BMP_H */
diff --git a/include/loaders/GP_GIF.h b/include/loaders/GP_GIF.h
index 23405e20..989259f4 100644
--- a/include/loaders/GP_GIF.h
+++ b/include/loaders/GP_GIF.h
@@ -29,9 +29,7 @@
#ifndef LOADERS_GP_GIF_H
#define LOADERS_GP_GIF_H
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-#include "loaders/GP_IO.h"
+#include "loaders/GP_Loader.h"
/*
* Reads first image found in GIF container from an IO stream.
@@ -51,4 +49,6 @@ GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback);
*/
int GP_MatchGIF(const void *buf);
+extern GP_Loader GP_GIF;
+
#endif /* LOADERS_GP_GIF_H */
diff --git a/include/loaders/GP_JP2.h b/include/loaders/GP_JP2.h
index 574cfbc5..ca2a029e 100644
--- a/include/loaders/GP_JP2.h
+++ b/include/loaders/GP_JP2.h
@@ -29,9 +29,7 @@
#ifndef LOADERS_GP_JP2_H
#define LOADERS_GP_JP2_H
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-#include "loaders/GP_IO.h"
+#include "loaders/GP_Loader.h"
/*
* Reads a JPEG2000 from an IO stream.
@@ -51,4 +49,6 @@ GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback);
*/
int GP_MatchJP2(const void *buf);
+extern GP_Loader GP_JP2;
+
#endif /* LOADERS_GP_JP2_H */
diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h
index 93cd2df2..381c084c 100644
--- a/include/loaders/GP_JPG.h
+++ b/include/loaders/GP_JPG.h
@@ -29,10 +29,7 @@
#ifndef LOADERS_GP_JPG_H
#define LOADERS_GP_JPG_H
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-#include "loaders/GP_IO.h"
-#include "loaders/GP_MetaData.h"
+#include "loaders/GP_Loader.h"
/*
* Reads a JPEG from an IO stream.
@@ -64,4 +61,6 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
*/
int GP_MatchJPG(const void *buf);
+extern GP_Loader GP_JPG;
+
#endif /* LOADERS_GP_JPG_H */
diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h
index 3b5bc8f0..3860ac10 100644
--- a/include/loaders/GP_Loader.h
+++ b/include/loaders/GP_Loader.h
@@ -129,8 +129,20 @@ const GP_Loader *GP_MatchSignature(const void *buf);
*/
const GP_Loader *GP_MatchExtension(const char *path);
-void GP_LoaderRegister(GP_Loader *self);
+/*
+ * Registers additional loader.
+ *
+ * Returns zero on success, non-zero if table of loaders was is full.
+ */
+int GP_LoaderRegister(GP_Loader *self);
+/*
+ * Unregisters a loader.
+ *
+ * All library loaders are registered by default.
+ *
+ * You can unregister them using this function if you want.
+ */
void GP_LoaderUnregister(GP_Loader *self);
/*
diff --git a/include/loaders/GP_PCX.h b/include/loaders/GP_PCX.h
index f5ce05c1..bb57233a 100644
--- a/include/loaders/GP_PCX.h
+++ b/include/loaders/GP_PCX.h
@@ -29,9 +29,7 @@
#ifndef LOADERS_GP_PCX_H
#define LOADERS_GP_PCX_H
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-#include "loaders/GP_IO.h"
+#include "loaders/GP_Loader.h"
/*
* Reads a PCX from an IO stream.
@@ -51,4 +49,6 @@ GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback);
*/
int GP_MatchPCX(const void *buf);
+extern GP_Loader GP_PCX;
+
#endif /* LOADERS_GP_PCX_H */
diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h
index b99e7280..eb607010 100644
--- a/include/loaders/GP_PNG.h
+++ b/include/loaders/GP_PNG.h
@@ -29,10 +29,7 @@
#ifndef LOADERS_GP_PNG_H
#define LOADERS_GP_PNG_H
-#include "core/GP_ProgressCallback.h"
-#include "core/GP_Context.h"
-#include "loaders/GP_IO.h"
-#include "loaders/GP_MetaData.h"
+#include "loaders/GP_Loader.h"
/*
* Reads a PNG from an IO stream.
@@ -65,4 +62,6 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
*/
int GP_MatchPNG(const void *buf);
+extern GP_Loader GP_PNG;
+
#endif /* LOADERS_GP_PNG_H */
diff --git a/include/loaders/GP_PNM.h b/include/loaders/GP_PNM.h
index 4f2dd11d..13d5f4b4 100644
--- a/include/loaders/GP_PNM.h
+++ b/include/loaders/GP_PNM.h
@@ -23,9 +23,7 @@
#ifndef LOADERS_GP_PNM_H
#define LOADERS_GP_PNM_H
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-#include "loaders/GP_IO.h"
+#include "loaders/GP_Loader.h"
/*
* PBM Bitmap
@@ -88,4 +86,9 @@ int GP_MatchPPM(const void *buf);
*/
int GP_MatchPNM(const void *buf);
+extern GP_Loader GP_PBM;
+extern GP_Loader GP_PGM;
+extern GP_Loader GP_PPM;
+extern GP_Loader GP_PNM;
+
#endif /* LOADERS_GP_PNM_H */
diff --git a/include/loaders/GP_PSD.h b/include/loaders/GP_PSD.h
index d8cd2213..7c4bcf6c 100644
--- a/include/loaders/GP_PSD.h
+++ b/include/loaders/GP_PSD.h
@@ -29,9 +29,7 @@
#ifndef LOADERS_GP_PSD_H
#define LOADERS_GP_PSD_H
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-#include "loaders/GP_IO.h"
+#include "loaders/GP_Loader.h"
/*
* Reads a PSD from an IO stream.
@@ -55,4 +53,6 @@ GP_Context *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback);
*/
int GP_MatchPSD(const void *buf);
+extern GP_Loader GP_PSD;
+
#endif /* LOADERS_GP_PSD_H */
diff --git a/include/loaders/GP_PSP.h b/include/loaders/GP_PSP.h
index 1109bd9e..9cf6c058 100644
--- a/include/loaders/GP_PSP.h
+++ b/include/loaders/GP_PSP.h
@@ -31,9 +31,7 @@
#ifndef LOADERS_GP_PSP_H
#define LOADERS_GP_PSP_H
-#include "core/GP_ProgressCallback.h"
-#include "core/GP_Context.h"
-#include "loaders/GP_IO.h"
+#include "loaders/GP_Loader.h"
/*
* Reads a BMP from an IO stream.
@@ -53,4 +51,6 @@ GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback);
*/
int GP_MatchPSP(const void *buf);
+extern GP_Loader GP_PSP;
+
#endif /* LOADERS_GP_PSP_H */
diff --git a/include/loaders/GP_TIFF.h b/include/loaders/GP_TIFF.h
index 8c7c45fd..ef5e4f33 100644
--- a/include/loaders/GP_TIFF.h
+++ b/include/loaders/GP_TIFF.h
@@ -23,9 +23,7 @@
#ifndef LOADERS_GP_TIFF_H
#define LOADERS_GP_TIFF_H
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-#include "loaders/GP_IO.h"
+#include "loaders/GP_Loader.h"
/*
* Reads first image in TIFF from an IO stream.
@@ -51,4 +49,6 @@ int GP_SaveTIFF(const GP_Context *src, const char *dst_path,
*/
int GP_MatchTIFF(const void *buf);
+extern GP_Loader GP_TIFF;
+
#endif /* LOADERS_GP_TIFF_H */
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index 1d9e9c20..9fcff422 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -905,3 +905,13 @@ int GP_SaveBMP(const GP_Context *src, const char *dst_path,
return 0;
}
+
+struct GP_Loader GP_BMP = {
+ .Read = GP_ReadBMP,
+ .Load = GP_LoadBMP,
+ .Save = GP_SaveBMP,
+ .Match = GP_MatchBMP,
+
+ .fmt_name = "BMP",
+ .extensions = {"bmp", "dib", NULL},
+};
diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c
index 0c286b97..6425d60a 100644
--- a/libs/loaders/GP_GIF.c
+++ b/libs/loaders/GP_GIF.c
@@ -400,3 +400,12 @@ GP_Context *GP_LoadGIF(const char GP_UNUSED(*src_path),
}
#endif /* HAVE_GIFLIB */
+
+struct GP_Loader GP_GIF = {
+ .Read = GP_ReadGIF,
+ .Load = GP_LoadGIF,
+ .Save = NULL,
+ .Match = GP_MatchGIF,
+ .fmt_name = "Graphics Interchange Format",
+ .extensions = {"gif", NULL},
+};
diff --git a/libs/loaders/GP_JP2.c b/libs/loaders/GP_JP2.c
index ef412ca8..f451b6f1 100644
--- a/libs/loaders/GP_JP2.c
+++ b/libs/loaders/GP_JP2.c
@@ -261,3 +261,13 @@ GP_Context *GP_LoadJP2(const char GP_UNUSED(*src_path),
}
#endif /* HAVE_OPENJPEG */
+
+struct GP_Loader GP_JP2 = {
+ .Read = GP_ReadJP2,
+ .Load = GP_LoadJP2,
+ .Save = NULL,
+ .Match = GP_MatchJP2,
+
+ .fmt_name = "JPEG 2000",
+ .extensions = {"jp2", "jpx", NULL},
+};
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index 6fd5dd28..ca14b180 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -593,3 +593,13 @@ int GP_SaveJPG(const GP_Context GP_UNUSED(*src),
}
#endif /* HAVE_JPEG */
+
+struct GP_Loader GP_JPG = {
+ .Read = GP_ReadJPG,
+ .Load = GP_LoadJPG,
+ .Save = GP_SaveJPG,
+ .Match = GP_MatchJPG,
+
+ .fmt_name = "JPEG",
+ .extensions = {"jpg", "jpeg", NULL},
+};
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index d88bf5f6..c3b74feb 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -39,205 +39,116 @@
#include "loaders/GP_Loaders.h"
#include "loaders/GP_Loader.h"
-static GP_Loader psd_loader = {
- .Read = GP_ReadPSD,
- .Load = GP_LoadPSD,
- .Save = NULL,
- .Match = GP_MatchPSD,
- .fmt_name = "Adobe Photoshop Image",
- .next = NULL,
- .extensions = {"psd", NULL},
+#define MAX_LOADERS 64
+
+static GP_Loader *loaders[MAX_LOADERS] = {
+ &GP_JPG,
+ &GP_PNG,
+ &GP_TIFF,
+ &GP_GIF,
+ &GP_BMP,
+ &GP_PBM,
+ &GP_PNM,
+ &GP_PPM,
+ &GP_PNM,
+ &GP_JP2,
+ &GP_PCX,
+ &GP_PSP,
+ &GP_PSD,
};
-static GP_Loader psp_loader = {
- .Read = GP_ReadPSP,
- .Load = GP_LoadPSP,
- .Save = NULL,
- .Match = GP_MatchPSP,
- .fmt_name = "Paint Shop Pro Image",
- .next = &psd_loader,
- .extensions = {"psp", "pspimage", NULL},
-};
-
-static GP_Loader pcx_loader = {
- .Read = GP_ReadPCX,
- .Load = GP_LoadPCX,
- .Save = NULL,
- .Match = GP_MatchPCX,
- .fmt_name = "ZSoft PCX",
- .next = &psp_loader,
- .extensions = {"pcx", NULL},
-};
-
-static GP_Loader pbm_loader = {
- .Read = GP_ReadPBM,
- .Load = GP_LoadPBM,
- .Save = GP_SavePBM,
- .Match = GP_MatchPBM,
- .fmt_name = "Netpbm portable Bitmap",
- .next = &pcx_loader,
- .extensions = {"pbm", NULL},
-};
-
-static GP_Loader pgm_loader = {
- .Read = GP_ReadPGM,
- .Load = GP_LoadPGM,
- .Save = GP_SavePGM,
- .Match = GP_MatchPGM,
- .fmt_name = "Netpbm portable Graymap",
- .next = &pbm_loader,
- .extensions = {"pgm", NULL},
-};
-
-static GP_Loader ppm_loader = {
- .Read = GP_ReadPPM,
- .Load = GP_LoadPPM,
- .Save = GP_SavePPM,
- .Match = GP_MatchPPM,
- .fmt_name = "Netpbm portable Pixmap",
- .next = &pgm_loader,
- .extensions = {"ppm", NULL},
-};
-
-static GP_Loader pnm_loader = {
- .Read = GP_ReadPNM,
- .Load = GP_LoadPNM,
- .Save = GP_SavePNM,
- /*
- * Avoid double Match
- * This format is covered by PBM, PGM and PPM
- */
- .Match = NULL,
- .fmt_name = "Netpbm portable Anymap",
- .next = &ppm_loader,
- .extensions = {"pnm", NULL},
-};
+static unsigned int get_last_loader(void)
+{
+ unsigned int i;
-static GP_Loader jp2_loader = {
- .Read = GP_ReadJP2,
- .Load = GP_LoadJP2,
- .Save = NULL,
- .Match = GP_MatchJP2,
- .fmt_name = "JPEG 2000",
- .next = &pnm_loader,
- .extensions = {"jp2", "jpx", NULL},
-};
+ for (i = 0; i < MAX_LOADERS; i++) {
+ if (!loaders[i])
+ return i ? i - 1 : 0;
+ }
-static GP_Loader bmp_loader = {
- .Read = GP_ReadBMP,
- .Load = GP_LoadBMP,
- .Save = GP_SaveBMP,
- .Match = GP_MatchBMP,
- .fmt_name = "BMP",
- .next = &jp2_loader,
- .extensions = {"bmp", "dib", NULL},
-};
+ return i - 1;
+}
-static GP_Loader gif_loader = {
- .Read = GP_ReadGIF,
- .Load = GP_LoadGIF,
- .Save = NULL,
- .Match = GP_MatchGIF,
- .fmt_name = "Graphics Interchange Format",
- .next = &bmp_loader,
- .extensions = {"gif", NULL},
-};
+int GP_LoaderRegister(GP_Loader *self)
+{
+ unsigned int i;
-static GP_Loader tiff_loader = {
- .Read = GP_ReadTIFF,
- .Load = GP_LoadTIFF,
- .Save = GP_SaveTIFF,
- .Match = GP_MatchTIFF,
- .fmt_name = "Tag Image File Format",
- .next = &gif_loader,
- .extensions = {"tif", "tiff", NULL},
-};
+ GP_DEBUG(1, "Registering loader for '%s'", self->fmt_name);
-static GP_Loader png_loader = {
- .Read = GP_ReadPNG,
- .Load = GP_LoadPNG,
- .Save = GP_SavePNG,
- .Match = GP_MatchPNG,
- .fmt_name = "Portable Network Graphics",
- .next = &tiff_loader,
- .extensions = {"png", NULL},
-};
+ /* We have to keep the last terminating NULL */
+ for (i = 0; i < MAX_LOADERS - 2; i++) {
+ if (loaders[i] == self) {
+ GP_DEBUG(1, "Loader '%s' allready registered",
+ self->fmt_name);
+ errno = EEXIST;
+ return 1;
+ }
-static GP_Loader jpeg_loader = {
- .Read = GP_ReadJPG,
- .Load = GP_LoadJPG,
- .Save = GP_SaveJPG,
- .Match = GP_MatchJPG,
- .fmt_name = "JPEG",
- .next = &png_loader,
- .extensions = {"jpg", "jpeg", NULL},
-};
+ if (!loaders[i])
+ break;
+ }
-static GP_Loader *loaders = &jpeg_loader;
-static GP_Loader *loaders_last = &psp_loader;
+ if (loaders[i]) {
+ GP_DEBUG(1, "Loaders table is full");
+ errno = ENOSPC;
+ return 1;
+ }
-void GP_LoaderRegister(GP_Loader *self)
-{
- GP_DEBUG(1, "Registering loader for '%s'", self->fmt_name);
+ loaders[i] = self;
- self->next = NULL;
- loaders_last->next = self;
+ return 0;
}
void GP_LoaderUnregister(GP_Loader *self)
{
- struct GP_Loader *i;
+ unsigned int i, last = get_last_loader();
if (self == NULL)
return;
GP_DEBUG(1, "Unregistering loader for '%s'", self->fmt_name);
- for (i = loaders; i != NULL; i = i->next) {
- if (i->next == self)
- break;
- }
-
- if (i == NULL) {
- GP_WARN("Loader '%s' (%p) wasn't registered",
- self->fmt_name, self);
- return;
+ for (i = 0; loaders[i]; i++) {
+ if (loaders[i] == self) {
+ loaders[i] = loaders[last];
+ loaders[last] = NULL;
+ return;
+ }
}
- i->next = self->next;
+ GP_WARN("Loader '%s' (%p) wasn't registered", self->fmt_name, self);
}
void GP_ListLoaders(void)
{
- struct GP_Loader *i;
- int j;
-
- for (i = loaders; i != NULL; i = i->next) {
- printf("Format: %sn", i->fmt_name);
- printf("Read:t%sn", i->Read ? "Yes" : "No");
- printf("Load:t%sn", i->Load ? "Yes" : "No");
- printf("Save:t%sn", i->Save ? "Yes" : "No");
- printf("Match:t%sn", i->Match ? "Yes" : "No");
+ unsigned int i, j;
+
+ for (i = 0; loaders[i]; i++) {
+ printf("Format: %sn", loaders[i]->fmt_name);
+ printf("Read:t%sn", loaders[i]->Read ? "Yes" : "No");
+ printf("Load:t%sn", loaders[i]->Load ? "Yes" : "No");
+ printf("Save:t%sn", loaders[i]->Save ? "Yes" : "No");
+ printf("Match:t%sn", loaders[i]->Match ? "Yes" : "No");
printf("Extensions: ");
- for (j = 0; i->extensions[j] != NULL; j++)
- printf("%s ", i->extensions[j]);
+ for (j = 0; loaders[i]->extensions[j] != NULL; j++)
+ printf("%s ", loaders[i]->extensions[j]);
printf("n");
- if (i->next != NULL)
+ if (loaders[i+1] != NULL)
printf("n");
}
}
static struct GP_Loader *loader_by_extension(const char *ext)
{
- struct GP_Loader *i;
- int j;
-
- for (i = loaders; i != NULL; i = i->next) {
- for (j = 0; i->extensions[j] != NULL; j++) {
- if (!strcasecmp(ext, i->extensions[j])) {
- GP_DEBUG(1, "Found loader '%s'", i->fmt_name);
- return i;
+ unsigned int i, j;
+
+ for (i = 0; loaders[i]; i++) {
+ for (j = 0; loaders[i]->extensions[j] != NULL; j++) {
+ if (!strcasecmp(ext, loaders[i]->extensions[j])) {
+ GP_DEBUG(1, "Found loader '%s'",
+ loaders[i]->fmt_name);
+ return loaders[i];
}
}
}
@@ -460,12 +371,12 @@ int GP_SaveImage(const GP_Context *src, const char *dst_path,
const GP_Loader *GP_MatchSignature(const void *buf)
{
- struct GP_Loader *i;
+ unsigned int i;
- for (i = loaders; i != NULL; i = i->next) {
- if (i->Match && i->Match(buf) == 1) {
- GP_DEBUG(1, "Found loader '%s'", i->fmt_name);
- return i;
+ for (i = 0; loaders[i]; i++) {
+ if (loaders[i]->Match && loaders[i]->Match(buf) == 1) {
+ GP_DEBUG(1, "Found loader '%s'", loaders[i]->fmt_name);
+ return loaders[i];
}
}
diff --git a/libs/loaders/GP_PCX.c b/libs/loaders/GP_PCX.c
index 8d92c0f2..b04dc41b 100644
--- a/libs/loaders/GP_PCX.c
+++ b/libs/loaders/GP_PCX.c
@@ -565,3 +565,13 @@ GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback)
return res;
}
+
+struct GP_Loader GP_PCX = {
+ .Read = GP_ReadPCX,
+ .Load = GP_LoadPCX,
+ .Save = NULL,
+ .Match = GP_MatchPCX,
+
+ .fmt_name = "ZSoft PCX",
+ .extensions = {"pcx", NULL},
+};
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 50f5fcdf..2da8bcef 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -653,3 +653,13 @@ int GP_SavePNG(const GP_Context GP_UNUSED(*src),
}
#endif /* HAVE_LIBPNG */
+
+GP_Loader GP_PNG = {
+ .Read = GP_ReadPNG,
+ .Load = GP_LoadPNG,
+ .Save = GP_SavePNG,
+ .Match = GP_MatchPNG,
+
+ .fmt_name = "Portable Network Graphics",
+ .extensions = {"png", NULL},
+};
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 1a17e530..63bb5361 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -1226,3 +1226,47 @@ int GP_SavePNM(const GP_Context *src, const char *dst_path,
return 1;
}
}
+
+struct GP_Loader GP_PBM = {
+ .Read = GP_ReadPBM,
+ .Load = GP_LoadPBM,
+ .Save = GP_SavePBM,
+ .Match = GP_MatchPBM,
+
+ .fmt_name = "Netpbm portable Bitmap",
+ .extensions = {"pbm", NULL},
+};
+
+struct GP_Loader GP_PGM = {
+ .Read = GP_ReadPGM,
+ .Load = GP_LoadPGM,
+ .Save = GP_SavePGM,
+ .Match = GP_MatchPGM,
+
+ .fmt_name = "Netpbm portable Graymap",
+ .extensions = {"pgm", NULL},
+};
+
+struct GP_Loader GP_PPM = {
+ .Read = GP_ReadPPM,
+ .Load = GP_LoadPPM,
+ .Save = GP_SavePPM,
+ .Match = GP_MatchPPM,
+
+ .fmt_name = "Netpbm portable Pixmap",
+ .extensions = {"ppm", NULL},
+};
+
+struct GP_Loader GP_PNM = {
+ .Read = GP_ReadPNM,
+ .Load = GP_LoadPNM,
+ .Save = GP_SavePNM,
+ /*
+ * Avoid double Match
+ * This format is covered by PBM, PGM and PPM
+ */
+ .Match = NULL,
+
+ .fmt_name = "Netpbm portable Anymap",
+ .extensions = {"pnm", NULL},
+};
diff --git a/libs/loaders/GP_PSD.c b/libs/loaders/GP_PSD.c
index a3e5030d..5ef73f11 100644
--- a/libs/loaders/GP_PSD.c
+++ b/libs/loaders/GP_PSD.c
@@ -829,3 +829,13 @@ GP_Context *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback)
return res;
}
+
+struct GP_Loader GP_PSD = {
+ .Read = GP_ReadPSD,
+ .Load = GP_LoadPSD,
+ .Save = NULL,
+ .Match = GP_MatchPSD,
+
+ .fmt_name = "Adobe Photoshop Image",
+ .extensions = {"psd", NULL},
+};
diff --git a/libs/loaders/GP_PSP.c b/libs/loaders/GP_PSP.c
index d99ca03d..bacd4b9b 100644
--- a/libs/loaders/GP_PSP.c
+++ b/libs/loaders/GP_PSP.c
@@ -507,3 +507,12 @@ GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback)
return res;
}
+
+struct GP_Loader GP_PSP = {
+ .Read = GP_ReadPSP,
+ .Load = GP_LoadPSP,
+ .Save = NULL,
+ .Match = GP_MatchPSP,
+ .fmt_name = "Paint Shop Pro Image",
+ .extensions = {"psp", "pspimage", NULL},
+};
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index 65513c77..1ea06554 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -762,3 +762,13 @@ int GP_SaveTIFF(const GP_Context GP_UNUSED(*src),
}
#endif /* HAVE_TIFF */
+
+struct GP_Loader GP_TIFF = {
+ .Read = GP_ReadTIFF,
+ .Load = GP_LoadTIFF,
+ .Save = GP_SaveTIFF,
+ .Match = GP_MatchTIFF,
+
+ .fmt_name = "Tag Image File Format",
+ .extensions = {"tif", "tiff", NULL},
+};
diff --git a/tests/loaders/Loader.c b/tests/loaders/Loader.c
new file mode 100644
index 00000000..4494825e
--- /dev/null
+++ b/tests/loaders/Loader.c
@@ -0,0 +1,164 @@
+/*****************************************************************************
+ * 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-2014 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <errno.h>
+#include <core/GP_Common.h>
+#include <loaders/GP_Loaders.h>
+
+#include "tst_test.h"
+
+static GP_Loader dummy_loaders[1000];
+
+static int register_max_loaders(void)
+{
+ unsigned int cnt = 0, i;
+
+ for (;;) {
+ if (GP_LoaderRegister(&dummy_loaders[cnt])) {
+ if (errno != ENOSPC) {
+ tst_msg("Wrong errno %s (%i), expected ENOSPC",
+ tst_strerr(errno), errno);
+ return TST_FAILED;
+ }
+ break;
+ }
+ cnt++;
+
+ if (cnt >= GP_ARRAY_SIZE(dummy_loaders)) {
+ tst_msg("Failed to reach the max after %u", cnt);
+ return TST_FAILED;
+ }
+ }
+
+ tst_msg("Registered %u loaders", cnt);
+
+ /* Let's provoke SEGFAULT by walking the loaders list */
+ GP_ListLoaders();
+
+ for (i = 0; i < cnt; i++)
+ GP_LoaderUnregister(&dummy_loaders[i]);
+
+ for (i = 0; i < cnt; i++) {
+ if (GP_LoaderRegister(&dummy_loaders[i])) {
+ tst_msg("Failed to register %u loader (max=%u)",
+ i, cnt);
+ return TST_FAILED;
+ }
+ }
+
+ for (i = 0; i < cnt; i++)
+ GP_LoaderUnregister(&dummy_loaders[cnt - i - 1]);
+
+ return TST_SUCCESS;
+}
+
+static int register_loader_twice(void)
+{
+ int ret;
+
+ if (GP_LoaderRegister(dummy_loaders)) {
+ tst_msg("Failed to register loader %s (%i)",
+ tst_strerr(errno), errno);
+ return TST_FAILED;
+ }
+
+ if (GP_LoaderRegister(dummy_loaders)) {
+ if (errno != EEXIST) {
+ tst_msg("Loader failed but errno %s (%i)",
+ tst_strerr(errno), errno);
+ ret = TST_FAILED;
+ goto exit;
+ }
+
+ tst_msg("Second attempt to register loader fails with EEXIST");
+ ret = TST_SUCCESS;
+ goto exit;
+ }
+
+ tst_msg("Second attempt to register loader succeded");
+ ret = TST_FAILED;
+exit:
+ GP_LoaderUnregister(dummy_loaders);
+ return ret;
+}
+
+static GP_Loader test_loader = {
+ .fmt_name = "TEST",
+ .extensions = {"test", NULL},
+};
+
+static int loader_by_extension(void)
+{
+ const GP_Loader *loader;
+ int err = 0;
+
+ if (GP_LoaderRegister(&test_loader)) {
+ tst_msg("Failed to register loader %s (%i)",
+ tst_strerr(errno), errno);
+ return TST_FAILED;
+ }
+
+ loader = GP_MatchExtension("file.jpg");
+
+ if (loader != &GP_JPG) {
+ tst_msg("Failed to get JPEG loader");
+ err++;
+ } else {
+ tst_msg("Succeded to get JPEG loader");
+ }
+
+ loader = GP_MatchExtension("file.test");
+
+ if (loader != &test_loader) {
+ tst_msg("Failed to get registered TEST loader");
+ err++;
+ } else {
+ tst_msg("Succeded to get TEST loader");
+ }
+
+ GP_LoaderUnregister(&test_loader);
+
+ if (err)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Loader",
+ .tests = {
+ /* Loader Register tests */
+ {.name = "LoaderRegister() max",
+ .tst_fn = register_max_loaders,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "LoaderRegister() twice",
+ .tst_fn = register_loader_twice,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "MatchExtension()",
+ .tst_fn = loader_by_extension,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = NULL},
+ }
+};
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index fb56086d..c483d412 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -2,11 +2,11 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c ZIP.c GIF.c IO.c PNM.c PCX.c- JPG.c
+ JPG.c Loader.c
GENSOURCES=SaveLoad.gen.c SaveAbort.gen.c
APPS=loaders_suite PNG PBM PGM PPM PNM SaveLoad.gen SaveAbort.gen ZIP GIF PCX- IO JPG
+ IO JPG Loader
include ../tests.mk
diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt
index adf857ea..dacb0f56 100644
--- a/tests/loaders/test_list.txt
+++ b/tests/loaders/test_list.txt
@@ -10,5 +10,6 @@ PNM
PCX
ZIP
IO
+Loader
SaveLoad.gen
SaveAbort.gen
http://repo.or.cz/w/gfxprim.git/commit/4bec01e5af42cb68e680f3a6d452d543b8c4…
commit 4bec01e5af42cb68e680f3a6d452d543b8c4d004
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 10:51:41 2014 +0200
tests: filters: Fix Makefile.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/filters/Makefile b/tests/filters/Makefile
index 8834428e..75889b5b 100644
--- a/tests/filters/Makefile
+++ b/tests/filters/Makefile
@@ -1,7 +1,7 @@
TOPDIR=../..
include $(TOPDIR)/pre.mk
-CSOURCES=FilterMirrorH.c
+CSOURCES=FilterMirrorH.c common.c
GENSOURCES=APICoverage.gen.c FiltersCompare.gen.c
@@ -11,8 +11,6 @@ include ../tests.mk
FilterMirrorH: common.o
-CLEAN+=common.o
-
include $(TOPDIR)/gen.mk
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
http://repo.or.cz/w/gfxprim.git/commit/e341668ccad607f9843386e206105f086ae3…
commit e341668ccad607f9843386e206105f086ae307d0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 13 10:43:37 2014 +0200
tests: framework add tst_strerr()
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/framework/tst_msg.c b/tests/framework/tst_msg.c
index b4f150fb..e3fd07f5 100644
--- a/tests/framework/tst_msg.c
+++ b/tests/framework/tst_msg.c
@@ -92,3 +92,58 @@ void tst_msg_print(const struct tst_msg_store *self)
for (msg = self->first; msg != NULL; msg = msg->next)
fprintf(stderr, "%c: %sn", type_to_char(msg->type), msg->msg);
}
+
+#define ERR(err) + case err: + return #err +
+const char *tst_strerr(int err)
+{
+ switch (err) {
+ case 0:
+ return "SUCCESS";
+ /* asm-generic/errno-base.h */
+ ERR(EPERM);
+ ERR(ENOENT);
+ ERR(ESRCH);
+ ERR(EINTR);
+ ERR(EIO);
+ ERR(ENXIO);
+ ERR(E2BIG);
+ ERR(ENOEXEC);
+ ERR(EBADF);
+ ERR(ECHILD);
+ ERR(EAGAIN);
+ ERR(ENOMEM);
+ ERR(EACCES);
+ ERR(EFAULT);
+ ERR(ENOTBLK);
+ ERR(EBUSY);
+ ERR(EEXIST);
+ ERR(EXDEV);
+ ERR(ENODEV);
+ ERR(ENOTDIR);
+ ERR(EISDIR);
+ ERR(EINVAL);
+ ERR(ENFILE);
+ ERR(EMFILE);
+ ERR(ENOTTY);
+ ERR(ETXTBSY);
+ ERR(EFBIG);
+ ERR(ENOSPC);
+ ERR(ESPIPE);
+ ERR(EROFS);
+ ERR(EMLINK);
+ ERR(EPIPE);
+ ERR(EDOM);
+ ERR(ERANGE);
+
+ /* a few from asm-generic/errno.h */
+ ERR(EDEADLK);
+ ERR(ENAMETOOLONG);
+ ERR(ENOSYS);
+ ERR(ECANCELED);
+ default:
+ return "???";
+ }
+}
diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h
index 4d65b1b6..182d96f5 100644
--- a/tests/framework/tst_test.h
+++ b/tests/framework/tst_test.h
@@ -130,4 +130,9 @@ int tst_warn(const char *fmt, ...)
int tst_err(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
+/*
+ * Translates errno number into short string, i.e. EFOO
+ */
+const char *tst_strerr(int err);
+
#endif /* TST_TEST_H */
-----------------------------------------------------------------------
Summary of changes:
build/syms/Loaders_symbols.txt | 13 ++
include/loaders/GP_BMP.h | 7 +-
include/loaders/GP_GIF.h | 6 +-
include/loaders/GP_JP2.h | 6 +-
include/loaders/GP_JPG.h | 7 +-
include/loaders/GP_Loader.h | 33 +++--
include/loaders/GP_PCX.h | 6 +-
include/loaders/GP_PNG.h | 7 +-
include/loaders/GP_PNM.h | 9 +-
include/loaders/GP_PSD.h | 6 +-
include/loaders/GP_PSP.h | 6 +-
include/loaders/GP_TIFF.h | 6 +-
libs/loaders/GP_BMP.c | 25 ++--
libs/loaders/GP_GIF.c | 37 ++----
libs/loaders/GP_JP2.c | 37 ++----
libs/loaders/GP_JPG.c | 42 +++----
libs/loaders/GP_Loader.c | 279 +++++++++++++++------------------------
libs/loaders/GP_PCX.c | 22 +--
libs/loaders/GP_PNG.c | 42 +++----
libs/loaders/GP_PNM.c | 136 +++++++++-----------
libs/loaders/GP_PSD.c | 22 +--
libs/loaders/GP_PSP.c | 23 +--
libs/loaders/GP_TIFF.c | 42 +++----
tests/filters/Makefile | 4 +-
tests/framework/tst_msg.c | 55 ++++++++
tests/framework/tst_test.h | 5 +
tests/loaders/Loader.c | 164 +++++++++++++++++++++++
tests/loaders/Makefile | 4 +-
tests/loaders/test_list.txt | 1 +
29 files changed, 572 insertions(+), 480 deletions(-)
create mode 100644 tests/loaders/Loader.c
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.")
1
0
10 Jun '14
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 13195186d44e871af057bda262ddf8467ff8049c (commit)
via 22c52a6b72540d2922c0ef48ce4ebf83f21c92e7 (commit)
via 29377414caa32964443fdf5e6bd557906f1c763b (commit)
via dbe87667ad5796a4294f74f54ad1abf5dd8c90e8 (commit)
from 425038462f7fe79ed853487a0ce66ecd927d1c8f (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/13195186d44e871af057bda262ddf8467ff8…
commit 13195186d44e871af057bda262ddf8467ff8049c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 10 19:11:32 2014 +0200
loaders/GP_IOZlib: Fix compilation without zlib.h
Move include <zlib.h> after the #ifdef HAVE_ZLIB guards.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_IOZlib.c b/libs/loaders/GP_IOZlib.c
index 21b7fc72..f62c831e 100644
--- a/libs/loaders/GP_IOZlib.c
+++ b/libs/loaders/GP_IOZlib.c
@@ -22,15 +22,16 @@
#include "../../config.h"
-#ifdef HAVE_ZLIB
-
-#include <zlib.h>
#include <errno.h>
#include <stdint.h>
#include <core/GP_Debug.h>
#include <core/GP_Common.h>
#include <loaders/GP_IOZlib.h>
+#ifdef HAVE_ZLIB
+
+#include <zlib.h>
+
#define BUFS 512u
struct priv {
@@ -255,4 +256,5 @@ int GP_IOZlibReset(GP_IO *io, GP_IO *sub_io, size_t comp_size)
errno = ENOSYS;
return 1;
}
+
#endif /* HAVE_ZLIB */
http://repo.or.cz/w/gfxprim.git/commit/22c52a6b72540d2922c0ef48ce4ebf83f21c…
commit 22c52a6b72540d2922c0ef48ce4ebf83f21c92e7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jun 8 22:22:31 2014 +0200
gentoo: Add doc use flag for ebuild.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/gentoo/media-libs/gfxprim/Manifest b/gentoo/media-libs/gfxprim/Manifest
index 091cf8b2..cac0c246 100644
--- a/gentoo/media-libs/gfxprim/Manifest
+++ b/gentoo/media-libs/gfxprim/Manifest
@@ -1,4 +1,4 @@
AUX configure-more-compatible-with-autoconf.patch 5335 SHA256 54f7614efee554a3ce8d90835df909a3e66272896018f65c600d0d93c038513e SHA512 6e55396524c0d9ce14f4cde643d8ff09fa04bee8437e64c3701e7e6c833abe902b9abdcf02ea883f29466c10e66836b11cc26755c91594e3a56ea60dd0e6be9b WHIRLPOOL b9f7a9cb54ca5af28dcc8bd1100857b8ddc6c178cd4572977ed6a914fa8ad6f5b8e8addbed2070250bcf9c15c3e28875c80bbe3f0b94f8c98933e275634aff65
DIST gfxprim-1.0.0_rc1.tar.bz2 326144 SHA256 0c543f45fa779a9503944723a7c9c449688e0fd66207f8adcc99cc667eed5582 SHA512 7481006d80d8ffc8302e1bc11e9b19253e37ed562ff465ac4028dcd73c6bfae073bad859204c3d7917d5eaebf38080802ef0463232eb436075addc9bd60af219 WHIRLPOOL 5cdf9008ec41752063556e98238a0cbeb1b3c8d1ef7fe899e632942b5e9d5d19955f4e097146fb385c0829137770463f1b36dd41737550de1bcfe07bdcf9f217
-EBUILD gfxprim-1.0.0_rc1.ebuild 1489 SHA256 ea09af7501316d26ef907c1f37e2329ae422202a57e470634f8a496906130c3f SHA512 d546f7f7fd0088f65993a238f0963c8ca4b5756a5fedbda57517cc49844f7e78b1675749a954e9e62dddd7e70bdb5132f4cd5f1f631b0abe8c3f321e6761576b WHIRLPOOL ac8f36b8bbf0ac71e35621c60cf7f1720d94e5574bcc40f6b20b2bb44f118e9b92571c9111f8fc57d404e95b16050261b67b193e004dbe85467b1de50940d539
-EBUILD gfxprim-9999.ebuild 1489 SHA256 ea09af7501316d26ef907c1f37e2329ae422202a57e470634f8a496906130c3f SHA512 d546f7f7fd0088f65993a238f0963c8ca4b5756a5fedbda57517cc49844f7e78b1675749a954e9e62dddd7e70bdb5132f4cd5f1f631b0abe8c3f321e6761576b WHIRLPOOL ac8f36b8bbf0ac71e35621c60cf7f1720d94e5574bcc40f6b20b2bb44f118e9b92571c9111f8fc57d404e95b16050261b67b193e004dbe85467b1de50940d539
+EBUILD gfxprim-1.0.0_rc1.ebuild 1751 SHA256 d9c39ce74614baff4a752f10511f5de300ba90f1de52f4e622ae6ce318592763 SHA512 860a50e046f5e663558aefe33f83ebf63befc5b8ad26ff7d83a8938d1d2e8d2305f2cf54a622d2de66df313dd80a49204ff703bde4c4c95e999770b3cb5ad49a WHIRLPOOL 427ed83721e48f7faa5ac721652c0c51b04ddf835c13e99a3acd5cbb92590b422b91ef7c4f5c57915543a4e82855286230da33fe90587e78b057f63eaf8a09e8
+EBUILD gfxprim-9999.ebuild 1751 SHA256 d9c39ce74614baff4a752f10511f5de300ba90f1de52f4e622ae6ce318592763 SHA512 860a50e046f5e663558aefe33f83ebf63befc5b8ad26ff7d83a8938d1d2e8d2305f2cf54a622d2de66df313dd80a49204ff703bde4c4c95e999770b3cb5ad49a WHIRLPOOL 427ed83721e48f7faa5ac721652c0c51b04ddf835c13e99a3acd5cbb92590b422b91ef7c4f5c57915543a4e82855286230da33fe90587e78b057f63eaf8a09e8
diff --git a/gentoo/media-libs/gfxprim/gfxprim-1.0.0_rc1.ebuild b/gentoo/media-libs/gfxprim/gfxprim-1.0.0_rc1.ebuild
index c748fa3b..e7f27e78 100644
--- a/gentoo/media-libs/gfxprim/gfxprim-1.0.0_rc1.ebuild
+++ b/gentoo/media-libs/gfxprim/gfxprim-1.0.0_rc1.ebuild
@@ -20,7 +20,7 @@ HOMEPAGE="http://gfxprim.ucw.cz/"
LICENSE="LGPL-2.1+"
SLOT="0"
-IUSE="jpeg png gif tiff jpeg2k freetype X sdl aalib python"
+IUSE="jpeg png gif tiff jpeg2k freetype X sdl aalib python doc"
RDEPEND="jpeg? ( virtual/jpeg )
png? ( media-libs/libpng )
@@ -31,6 +31,8 @@ RDEPEND="jpeg? ( virtual/jpeg )
X? ( x11-libs/libX11 )
sdl? ( media-libs/libsdl )
aalib? ( media-libs/aalib )
+ doc? ( app-text/asciidoc dev-util/source-highlight media-gfx/graphviz
+ app-text/dvipng virtual/latex-base )
"
DEPEND="$RDEPEND
@@ -39,7 +41,7 @@ DEPEND="$RDEPEND
"
src_prepare() {
- if [ "${PV}" != 9999 ]; then
+ if [ "${PV}" == "1.0.0_rc1" ]; then
epatch ${FILESDIR}/configure-more-compatible-with-autoconf.patch
fi
}
@@ -58,3 +60,13 @@ src_configure() {
econf ${conf}
}
+
+src_compile() {
+ default
+ use doc && cd doc && emake
+}
+
+src_install() {
+ default
+ use doc && cd doc && emake DESTDIR="${D}" install
+}
http://repo.or.cz/w/gfxprim.git/commit/29377414caa32964443fdf5e6bd557906f1c…
commit 29377414caa32964443fdf5e6bd557906f1c763b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jun 8 21:14:44 2014 +0200
doc: Add make install
Now doc installs into 'docdir'
(defaults to $(prefix)usr/doc/libgfxprim-$(version))
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/configure b/configure
index 215db43c..4208355a 100755
--- a/configure
+++ b/configure
@@ -364,6 +364,7 @@ if __name__ == '__main__':
'libdir' : ['', 'Where to install libraries'],
'includedir' : ['include', 'Where to install headers'],
'mandir' : ['share/man', 'Where to install man pages'],
+ 'docdir' : ['share/doc/', 'Where to install documentation'],
# Here comes autoconf compatibility cruft, not used for anything yet
'infodir' : ['share/info', 'Where to install info pages'],
'datadir' : ['share', 'Where to place readonly arch independend datafiles'],
diff --git a/doc/Makefile b/doc/Makefile
index 2b56050d..9c1bcfb7 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,3 +1,6 @@
+TOPDIR=..
+include $(TOPDIR)/config.mk
+
SOURCES=index.html about.txt context.txt loaders.txt filters.txt basic_types.txt gfx.txt backends.txt gamma.txt grabbers.txt environment_variables.txt debug.txt core.txt input.txt @@ -80,3 +83,8 @@ CLEAN+=$(PAGES)
clean:
rm -f $(CLEAN)
+
+INSTALL_DOC=$(PAGES) *.png *.svg asciidoc.css images/*/*.png
+install: $(INSTALL_DOC)
+
+include $(TOPDIR)/install.mk
diff --git a/install.mk b/install.mk
index 4b777c08..201ef01f 100644
--- a/install.mk
+++ b/install.mk
@@ -1,13 +1,13 @@
-ifdef DESTDIR
-BIN_DIR=$(DESTDIR)/$(bindir)
-else
-BIN_DIR=$(bindir)
-endif
+include $(TOPDIR)/libver.mk
ifdef DESTDIR
+BIN_DIR=$(DESTDIR)/$(bindir)
MAN_DIR=$(DESTDIR)/$(mandir)/man1
+DOC_DIR=$(DESTDIR)/$(docdir)/libgfxprim-$(LIB_VERSION)
else
MAN_DIR=$(mandir)/man1
+BIN_DIR=$(bindir)
+DOC_DIR=$(docdir)/libgfxprim-$(LIB_MAJOR)-$(LIB_MINOR)
endif
install:
@@ -32,3 +32,14 @@ else
@for i in $(INSTALL_MAN); do echo "CP $$i $(MAN_DIR)"; install "$$i" "$(MAN_DIR)"; done
endif
endif
+
+ifdef INSTALL_DOC
+ifdef VERBOSE
+ install -d "$(DOC_DIR)"
+ for i in $(INSTALL_DOC); do install -D -m 644 "$$i" "$(DOC_DIR)/$$i"; done
+else
+ @install -d "$(DOC_DIR)"
+ @echo "MKDIR $(DOC_DIR)"
+ @for i in $(INSTALL_DOC); do echo "CP $$i $(DOC_DIR)/$$i"; install -D -m 644 "$$i" "$(DOC_DIR)/$$i"; done
+endif
+endif
http://repo.or.cz/w/gfxprim.git/commit/dbe87667ad5796a4294f74f54ad1abf5dd8c…
commit dbe87667ad5796a4294f74f54ad1abf5dd8c90e8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 6 16:27:57 2014 +0200
build: Link gfxprim libs with third party libs
Pass LDLIBS for third party libraries to linker when gfxprim-foo
libraries are created.
This allows us to link binaries only agains the gfxprim-foo libs
(because the third party libs are loaded as dependencies of the
particual gfxprim-foo library) and we don't have to recompile them
when list of libraries GFXprim is linked agains changes.
This commit resolves #6
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/app.mk b/app.mk
index ccfdef10..2e10fff8 100644
--- a/app.mk
+++ b/app.mk
@@ -3,8 +3,8 @@ CLEAN+=$(APPS)
%: %.o
ifdef VERBOSE
- $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $^ $(LDLIBS) $(LDLIBS_GP) -Wl,--end-group -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $^ $(LDLIBS) -lgfxprim -Wl,--end-group -o $@
else
@echo "LD $@"
- @$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $^ $(LDLIBS) $(LDLIBS_GP) -Wl,--end-group -o $@
+ @$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $^ $(LDLIBS) -lgfxprim -Wl,--end-group -o $@
endif
diff --git a/build/Makefile b/build/Makefile
index b6cd8cb7..3053edfa 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -37,10 +37,10 @@ endif
$(DYNAMIC_LIB): $(LIB_OBJECTS)
ifdef VERBOSE
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -o $@
+ $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm $(LDLIBS_core) -o $@
else
@echo "LD $@"
- @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -o $@
+ @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -lm $(LDLIBS_core) -o $@
endif
$(SYMLINKS): $(DYNAMIC_LIB)
diff --git a/config.mk b/config.mk
index 82b349a0..ba6c3a86 100644
--- a/config.mk
+++ b/config.mk
@@ -18,9 +18,3 @@ endif
PYTHON=PYTHONPATH=$$PYTHONPATH:${PYLIBSDIR} ${PYTHON_BIN} -Werror
SWIGOPTS=-w322,314 -I/usr/include/
-
-# Linker flags
-LDLIBS_GP=$(shell $(TOPDIR)/gfxprim-config --libs)
-LDLIBS_LOADERS=$(shell $(TOPDIR)/gfxprim-config --libs-loaders)
-LDLIBS_BACKENDS=$(shell $(TOPDIR)/gfxprim-config --libs-backends)
-LDLIBS_GRABBERS=$(shell $(TOPDIR)/gfxprim-config --libs-grabbers)
diff --git a/configure b/configure
index b6e24fbf..215db43c 100755
--- a/configure
+++ b/configure
@@ -194,6 +194,11 @@ class libraries:
else:
f.write("HAVE_%s=non" % i[0].upper())
+ # Write all libraries the library should link with
+ for module in self.get_modules():
+ f.write("# %s linker flagsn" % (module))
+ f.write("LDLIBS_%s=" % (module))
+ f.write("%sn" % self.get_linker_flags(module))
#
# Return list of linker flags needed to build particular module
# (module may be core, loaders, backends, etc...
@@ -202,7 +207,11 @@ class libraries:
res = ''
for i in self.libraries:
if module in i[5] and self.results[i[0]]:
- res += ' ' + i[4]
+ if i[4] == '':
+ continue;
+ if res != '':
+ res += ' '
+ res += i[4]
return res
#
# Returns list of cflags needed to build module
@@ -214,6 +223,17 @@ class libraries:
res += ' ' + i[3]
return res
+ #
+ # Builds a list of GFXprim libraries that may need to be linked against
+ # third party libs
+ #
+ def get_modules(self):
+ modules = {}
+ for i in self.libraries:
+ for module in i[5]:
+ modules[module] = True
+ return modules.keys()
+
def die_screaming(msg):
sys.stderr.write("n************************************n")
sys.stderr.write("ERROR: ")
@@ -280,8 +300,7 @@ def write_config_mk(cfg, libs):
# Generate app compilation helper
#
def write_gfxprim_config(cfg, libs):
- modules = ['loaders', 'backends', 'grabbers']
-
+ modules = libs.get_modules()
f = open('gfxprim-config', 'w')
f.write('#!/bin/shn'
'#n# Generated by configure, do not edit directlyn#nn'
diff --git a/demos/bogoman/Makefile b/demos/bogoman/Makefile
index 83d156e0..a448feea 100644
--- a/demos/bogoman/Makefile
+++ b/demos/bogoman/Makefile
@@ -1,14 +1,14 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
INCLUDE=
-LDLIBS+=$(LDLIBS_BACKENDS)
+LDLIBS+=-lgfxprim-backends
APPS=bogoman
bogoman: bogoman_map.o bogoman_debug.o bogoman_loader.o bogoman_render.o
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile
index ed75f7a2..0abe0214 100644
--- a/demos/c_simple/Makefile
+++ b/demos/c_simple/Makefile
@@ -1,5 +1,4 @@
TOPDIR=../..
-
include $(TOPDIR)/pre.mk
SOURCES=$(shell echo *.c)
@@ -24,39 +23,39 @@ APPS=backend_example loaders_example loaders filters_symmetry gfx_koch ifeq ($(HAVE_LIBSDL),yes)
APPS+=SDL_glue
-SDL_glue: LDLIBS+=$(LDLIBS_BACKENDS)
+SDL_glue: LDLIBS+=$(shell sdl-config --libs) -lgfxprim-backends
endif
-showimage: LDLIBS+=$(LDLIBS_BACKENDS) $(LDLIBS_LOADERS)
-backend_example: LDLIBS+=$(LDLIBS_BACKENDS)
-backend_timers_example: LDLIBS+=$(LDLIBS_BACKENDS)
-virtual_backend_example: LDLIBS+=$(LDLIBS_BACKENDS)
-loaders_example: LDLIBS+=$(LDLIBS_LOADERS)
-loaders: LDLIBS+=$(LDLIBS_LOADERS)
-tmp_file: LDLIBS+=$(LDLIBS_LOADERS)
-filters_symmetry: LDLIBS+=$(LDLIBS_LOADERS)
-gfx_koch: LDLIBS+=$(LDLIBS_LOADERS)
-meta_data: LDLIBS+=$(LDLIBS_LOADERS)
-meta_data_dump: LDLIBS+=$(LDLIBS_LOADERS)
-v4l2_show: LDLIBS+=$(LDLIBS_GRABBERS) $(LDLIBS_BACKENDS)
-v4l2_grab: LDLIBS+=$(LDLIBS_GRABBERS) $(LDLIBS_LOADERS)
-convolution: LDLIBS+=$(LDLIBS_LOADERS)
-weighted_median: LDLIBS+=$(LDLIBS_LOADERS)
-shapetest: LDLIBS+=$(LDLIBS_BACKENDS)
-koch: LDLIBS+=$(LDLIBS_BACKENDS)
-input_example: LDLIBS+=$(LDLIBS_BACKENDS)
-fileview: LDLIBS+=$(LDLIBS_BACKENDS)
-linetest: LDLIBS+=$(LDLIBS_BACKENDS)
-randomshapetest: LDLIBS+=$(LDLIBS_BACKENDS)
-fonttest: LDLIBS+=$(LDLIBS_BACKENDS)
-textaligntest: LDLIBS+=$(LDLIBS_BACKENDS)
-loaders_register: LDLIBS+=$(LDLIBS_LOADERS)
-gaussian_noise: LDLIBS+=$(LDLIBS_LOADERS)
-blittest: LDLIBS+=$(LDLIBS_BACKENDS) $(LDLIBS_LOADERS)
-sin_AA: LDLIBS+=$(LDLIBS_BACKENDS)
-x11_windows: LDLIBS+=$(LDLIBS_BACKENDS)
-zip_container: LDLIBS+=$(LDLIBS_LOADERS) $(LDLIBS_BACKENDS)
-memory_io: LDLIBS+=$(LDLIBS_BACKENDS) $(LDLIBS_LOADERS)
+showimage: LDLIBS+=-lgfxprim-backends -lgfxprim-loaders
+backend_example: LDLIBS+=-lgfxprim-backends
+backend_timers_example: LDLIBS+=-lgfxprim-backends
+virtual_backend_example: LDLIBS+=-lgfxprim-backends -lm
+loaders_example: LDLIBS+=-lgfxprim-loaders
+loaders: LDLIBS+=-lgfxprim-loaders
+tmp_file: LDLIBS+=-lgfxprim-loaders
+filters_symmetry: LDLIBS+=-lgfxprim-loaders
+gfx_koch: LDLIBS+=-lgfxprim-loaders -lm
+meta_data: LDLIBS+=-lgfxprim-loaders
+meta_data_dump: LDLIBS+=-lgfxprim-loaders
+v4l2_show: LDLIBS+=-lgfxprim-grabbers -lgfxprim-backends
+v4l2_grab: LDLIBS+=-lgfxprim-grabbers -lgfxprim-loaders
+convolution: LDLIBS+=-lgfxprim-loaders
+weighted_median: LDLIBS+=-lgfxprim-loaders
+shapetest: LDLIBS+=-lgfxprim-backends
+koch: LDLIBS+=-lgfxprim-backends -lm
+input_example: LDLIBS+=-lgfxprim-backends
+fileview: LDLIBS+=-lgfxprim-backends
+linetest: LDLIBS+=-lgfxprim-backends -lm
+randomshapetest: LDLIBS+=-lgfxprim-backends
+fonttest: LDLIBS+=-lgfxprim-backends
+textaligntest: LDLIBS+=-lgfxprim-backends
+loaders_register: LDLIBS+=-lgfxprim-loaders
+gaussian_noise: LDLIBS+=-lgfxprim-loaders
+blittest: LDLIBS+=-lgfxprim-backends -lgfxprim-loaders
+sin_AA: LDLIBS+=-lgfxprim-backends -lm
+x11_windows: LDLIBS+=-lgfxprim-backends
+zip_container: LDLIBS+=-lgfxprim-loaders -lgfxprim-backends
+memory_io: LDLIBS+=-lgfxprim-backends -lgfxprim-loaders
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/demos/grinder/Makefile b/demos/grinder/Makefile
index 80e31e21..6e53dc32 100644
--- a/demos/grinder/Makefile
+++ b/demos/grinder/Makefile
@@ -5,7 +5,7 @@ CSOURCES=$(shell echo *.c)
INCLUDE=core gfx
LDLIBS+=-lrt -lm
-LDLIBS+=$(LDLIBS_LOADERS)
+LDLIBS+=-lgfxprim-loaders
APPS=grinder
diff --git a/demos/particle/Makefile b/demos/particle/Makefile
index 6204f936..7b553e56 100644
--- a/demos/particle/Makefile
+++ b/demos/particle/Makefile
@@ -4,7 +4,7 @@ CSOURCES=$(shell echo *.c)
INCLUDE=
LDFLAGS+=-L$(TOPDIR)/build/
-LDLIBS+=-lrt `$(TOPDIR)/gfxprim-config --libs --libs-backends`
+LDLIBS+=-lrt -lm -lgfxprim-backends
APPS=particle_demo
diff --git a/demos/spiv/Makefile b/demos/spiv/Makefile
index e3a5c15c..9376ee47 100644
--- a/demos/spiv/Makefile
+++ b/demos/spiv/Makefile
@@ -7,7 +7,7 @@ INCLUDE=
LDFLAGS+=-L$(TOPDIR)/build/
LDLIBS+=-lrt
-LDLIBS+=$(LDLIBS_LOADERS) $(LDLIBS_BACKENDS)
+LDLIBS+=-lgfxprim-loaders -lgfxprim-backends
APPS=spiv
diff --git a/demos/ttf2img/Makefile b/demos/ttf2img/Makefile
index 5fa8100f..636b04b8 100644
--- a/demos/ttf2img/Makefile
+++ b/demos/ttf2img/Makefile
@@ -1,13 +1,12 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
INCLUDE=
-LDLIBS+=-lm
-LDLIBS+=$(LDLIBS_LOADERS)
+LDLIBS+=-lgfxprim-loaders
APPS=ttf2img
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/lib.mk b/lib.mk
index ff44945f..6afa4626 100644
--- a/lib.mk
+++ b/lib.mk
@@ -11,8 +11,8 @@ ifeq ($(BUILDLIB),yes)
# Rules for single library, applied only when objects
# are not linked to the libgfxprim.so. This generates libgfxprim_$(LIBNAME).
#
-
include $(TOPDIR)/libver.mk
+include $(TOPDIR)/config.mk
LIB_NAME=libgfxprim-$(LIBNAME)
BUILD_DIR=$(TOPDIR)/build/
@@ -36,11 +36,11 @@ OBJS=$(CSOURCES:.c=.o)
$(BUILD_DIR)$(DYNAMIC_LIB): $(OBJS)
ifdef VERBOSE
rm -f $@
- $(CC) -fPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -o $@
+ $(CC) -fPIC --shared -Wl,-soname -Wl,$(SONAME) $(LDLIBS_$(LIBNAME)) $^ -o $@
else
@rm -f $(@)
@echo "LD $@"
- @$(CC) -fPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -o $@
+ @$(CC) -fPIC --shared -Wl,-soname -Wl,$(SONAME) $(LDLIBS_$(LIBNAME)) $^ -o $@
endif
$(BUILD_DIR)$(STATIC_LIB): $(OBJS)
@@ -66,8 +66,6 @@ else
# If we are not executed from the top Makefile, trigger
# libGP.so rebuild.
#
-include $(TOPDIR)/config.mk
-
ifndef TOP_MAKE
ALL+=rebuild_lib
diff --git a/pylib/gfxprim/backends/Makefile b/pylib/gfxprim/backends/Makefile
index 2353ed9c..38707caa 100644
--- a/pylib/gfxprim/backends/Makefile
+++ b/pylib/gfxprim/backends/Makefile
@@ -4,7 +4,7 @@ INCLUDE=core
include $(TOPDIR)/pre.mk
-LDLIBS+=$(LDLIBS_BACKENDS)
+LDLIBS+=-lgfxprim-backends
INSTALL_FILES+=_extend_backend.py
diff --git a/pylib/gfxprim/grabbers/Makefile b/pylib/gfxprim/grabbers/Makefile
index 2a804929..213a7e24 100644
--- a/pylib/gfxprim/grabbers/Makefile
+++ b/pylib/gfxprim/grabbers/Makefile
@@ -4,7 +4,7 @@ INCLUDE=core
include $(TOPDIR)/pre.mk
-LDLIBS+=$(LDLIBS_GRABBERS)
+LDLIBS+=-lgfxprim-grabbers
include $(TOPDIR)/pywrap.mk
include $(TOPDIR)/post.mk
diff --git a/pylib/gfxprim/loaders/Makefile b/pylib/gfxprim/loaders/Makefile
index 5daaf56f..2f150647 100644
--- a/pylib/gfxprim/loaders/Makefile
+++ b/pylib/gfxprim/loaders/Makefile
@@ -4,7 +4,7 @@ INCLUDE=core
include $(TOPDIR)/pre.mk
-LDLIBS+=$(LDLIBS_LOADERS)
+LDLIBS+=-lgfxprim-loaders
include $(TOPDIR)/pywrap.mk
include $(TOPDIR)/post.mk
diff --git a/pywrap.mk b/pywrap.mk
index 15b78c43..76d18b48 100644
--- a/pywrap.mk
+++ b/pywrap.mk
@@ -35,10 +35,10 @@ $(SWIG_C): ../common.i
$(SWIG_LIB): $(SWIG_C)
ifdef VERBOSE
- $(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) $(PYTHON_INCLUDE) --shared $(LDLIBS) $(LDLIBS_GP) -L$(TOPDIR)/build/ -o $@
+ $(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) $(PYTHON_INCLUDE) --shared $(LDLIBS) -lgfxprim -L$(TOPDIR)/build/ -o $@
else # VERBOSE
@echo "LD $@"
- @$(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) $(PYTHON_INCLUDE) --shared $(LDLIBS) $(LDLIBS_GP) -L$(TOPDIR)/build/ -o $@
+ @$(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) $(PYTHON_INCLUDE) --shared $(LDLIBS) -lgfxprim -L$(TOPDIR)/build/ -o $@
endif # VERBOSE
# Install python libraries into right places
-----------------------------------------------------------------------
Summary of changes:
app.mk | 4 +-
build/Makefile | 4 +-
config.mk | 6 --
configure | 26 +++++++-
demos/bogoman/Makefile | 4 +-
demos/c_simple/Makefile | 63 ++++++++++----------
demos/grinder/Makefile | 2 +-
demos/particle/Makefile | 2 +-
demos/spiv/Makefile | 2 +-
demos/ttf2img/Makefile | 5 +-
doc/Makefile | 8 +++
gentoo/media-libs/gfxprim/Manifest | 4 +-
gentoo/media-libs/gfxprim/gfxprim-1.0.0_rc1.ebuild | 16 ++++-
install.mk | 21 +++++--
lib.mk | 8 +--
libs/loaders/GP_IOZlib.c | 8 ++-
pylib/gfxprim/backends/Makefile | 2 +-
pylib/gfxprim/grabbers/Makefile | 2 +-
pylib/gfxprim/loaders/Makefile | 2 +-
pywrap.mk | 4 +-
20 files changed, 118 insertions(+), 75 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.")
1
0
27 May '14
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 425038462f7fe79ed853487a0ce66ecd927d1c8f (commit)
via 7b84c8bb9d3d8ac020b3460a3cec4d19450d130b (commit)
via 8c85a6820eef1c67fef1d2ca545eaaa478844c85 (commit)
via 9c8989f7e34a92c66193f44fe17952c68516d565 (commit)
from a19009feb951a42521104ff1d2657ce9fc77df99 (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/425038462f7fe79ed853487a0ce66ecd927d…
commit 425038462f7fe79ed853487a0ce66ecd927d1c8f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 27 22:34:00 2014 +0200
doc: Add two more python examples.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/example_py_cam_view.txt b/doc/example_py_cam_view.txt
new file mode 100644
index 00000000..209a7343
--- /dev/null
+++ b/doc/example_py_cam_view.txt
@@ -0,0 +1,8 @@
+Camera Viewer
+-------------
+A simple program that shows video from camera (V4L2 device)
+
+[source,python]
+------------------------------------------------------------------
+include::../demos/py_simple/cam_view.py[]
+------------------------------------------------------------------
diff --git a/doc/example_py_font_style.txt b/doc/example_py_font_style.txt
new file mode 100644
index 00000000..49d3b760
--- /dev/null
+++ b/doc/example_py_font_style.txt
@@ -0,0 +1,8 @@
+Font Style
+----------
+A simple example that shows drawing with compiled in bitmap fonts.
+
+[source,python]
+------------------------------------------------------------------
+include::../demos/py_simple/font_style.py[]
+------------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/7b84c8bb9d3d8ac020b3460a3cec4d19450d…
commit 7b84c8bb9d3d8ac020b3460a3cec4d19450d130b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 27 22:25:53 2014 +0200
pywrap: Unbreak Fill after it was moved to core
After GP_Fill() was moved to core from gfx the python bindings were not
fixed correctly.
Now Fill() is available both in core and in gfx.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
index 96bf9be4..82b27f9e 100644
--- a/pylib/gfxprim/core/__init__.py
+++ b/pylib/gfxprim/core/__init__.py
@@ -156,6 +156,11 @@ def _init(module):
"Convert RGBA8888 (values 0-255) to context pixel type."
return c_core.GP_RGBAToPixel(int(r), int(g), int(b), int(a), self.pixel_type)
+ @extend(_context)
+ def Fill(self, pixel):
+ "Fills context with given pixel value."
+ return c_core.GP_Fill(self, pixel)
+
# Handle submodule methods such as context.gfx.Line(...)
_available_submodules = frozenset(['gfx', 'loaders', 'text', 'filters'])
@@ -201,7 +206,8 @@ def _init(module):
'^GP_PixelRGB.*$', # ...Lookup and ...Match
'^GP_PixelToRGB.*$', # Needs love
'^GP_RGB.*$', # Needs filtering
- ])
+ '^GP_Fill',
+ ])
module['Convert'] = c_core.GP_ContextConvertAlloc
diff --git a/pylib/gfxprim/gfx/__init__.py b/pylib/gfxprim/gfx/__init__.py
index dc2e9a94..daf99e11 100644
--- a/pylib/gfxprim/gfx/__init__.py
+++ b/pylib/gfxprim/gfx/__init__.py
@@ -36,13 +36,17 @@ def _init(module):
import_members(c_gfx, C, include=const_regexes, sub=strip_GP)
for name in [
- 'ArcSegment', 'Circle', 'Ellipse', 'Fill', 'FillCircle', 'FillEllipse',
+ 'ArcSegment', 'Circle', 'Ellipse', 'FillCircle', 'FillEllipse',
'FillRect', 'FillRect_AA', 'FillRing',
'FillTetragon', 'FillTriangle', 'HLine', 'HLineAA', 'Line', 'LineAA',
'PutPixelAA', 'Rect', 'Ring', 'Tetragon',
'Triangle', 'VLine', 'VLineAA']:
extend_submodule(GfxSubmodule, name, c_gfx.__getattribute__('GP_' + name))
+ @extend(GfxSubmodule)
+ def Fill(self, color):
+ self.ctx.Fill(color)
+
def flatten_coords(points):
"Helper for Polygon and FillPolygon coordinates"
l = []
http://repo.or.cz/w/gfxprim.git/commit/8c85a6820eef1c67fef1d2ca545eaaa47884…
commit 8c85a6820eef1c67fef1d2ca545eaaa478844c85
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 27 21:59:35 2014 +0200
demos/py_simple: New python gfxprim + Qt example
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/py_simple/gfxprim_qt.py b/demos/py_simple/gfxprim_qt.py
new file mode 100755
index 00000000..61eabb2d
--- /dev/null
+++ b/demos/py_simple/gfxprim_qt.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import sys
+from PySide import QtGui
+import gfxprim.core as core
+import gfxprim.loaders as loaders
+
+def getpixmap(path):
+ img = loaders.Load(path)
+ if img.pixel_type != core.C.PIXEL_BGR888:
+ img = img.Convert(core.C.PIXEL_BGR888)
+ qt_img = QtGui.QImage(img.ToByteArray(), img.w, img.h,
+ img.bytes_per_row, QtGui.QImage.Format_RGB888)
+ pix = QtGui.QPixmap.fromImage(qt_img)
+ return pix
+
+class ImageLabel(QtGui.QLabel):
+ def __init__(self, path, parent=None):
+ QtGui.QLabel.__init__(self, parent)
+
+ self.setWindowTitle(path)
+
+ self.pix = getpixmap(path)
+ self.setPixmap(self.pix)
+ size = self.pix.size()
+ self.setGeometry(100, 100, size.width(), size.height())
+
+def main():
+ app = QtGui.QApplication(sys.argv)
+ w = ImageLabel(sys.argv[1])
+ w.show()
+ sys.exit(app.exec_())
+
+if __name__ == '__main__':
+ main()
diff --git a/doc/example_py_qt.txt b/doc/example_py_qt.txt
new file mode 100644
index 00000000..354ab553
--- /dev/null
+++ b/doc/example_py_qt.txt
@@ -0,0 +1,9 @@
+Qt (PySide)
+-----------
+A simple program that shows how to combine Qt (link:http://pyside.org[PySide])
+with GFXprim in python.
+
+[source,python]
+------------------------------------------------------------------
+include::../demos/py_simple/gfxprim_qt.py[]
+------------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/9c8989f7e34a92c66193f44fe17952c68516…
commit 9c8989f7e34a92c66193f44fe17952c68516d565
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 27 21:55:40 2014 +0200
doc: Add C64 font example image
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/images/fonts/font_c64.png b/doc/images/fonts/font_c64.png
new file mode 100644
index 00000000..e868101f
Binary files /dev/null and b/doc/images/fonts/font_c64.png differ
diff --git a/doc/text.txt b/doc/text.txt
index 8a4a4cb4..e0264ff6 100644
--- a/doc/text.txt
+++ b/doc/text.txt
@@ -202,6 +202,9 @@ image::images/fonts/font_tiny_mono.png["Font Tiny Mono"]
.Font Tiny (GP_FontTiny)
image::images/fonts/font_tiny.png["Font Tiny"]
+.Font C64 (GP_FontC64)
+image::images/fonts/font_c64.png["Font C64"]
+
TrueType Fonts
~~~~~~~~~~~~~~
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/gfxprim_qt.py | 35 ++++++++++++++++++++
...ample_py_resize.txt => example_py_cam_view.txt} | 8 ++--
..._py_showimage.txt => example_py_font_style.txt} | 8 ++--
doc/example_py_qt.txt | 9 +++++
doc/images/fonts/font_c64.png | Bin 0 -> 2373 bytes
doc/text.txt | 3 ++
pylib/gfxprim/core/__init__.py | 8 ++++-
pylib/gfxprim/gfx/__init__.py | 6 +++-
8 files changed, 67 insertions(+), 10 deletions(-)
create mode 100755 demos/py_simple/gfxprim_qt.py
copy doc/{example_py_resize.txt => example_py_cam_view.txt} (53%)
copy doc/{example_py_showimage.txt => example_py_font_style.txt} (53%)
create mode 100644 doc/example_py_qt.txt
create mode 100644 doc/images/fonts/font_c64.png
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.")
1
0
27 May '14
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 a19009feb951a42521104ff1d2657ce9fc77df99 (commit)
from 0192d34fbb5325dc78143d0bb8438c6d2613aadd (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/a19009feb951a42521104ff1d2657ce9fc77…
commit a19009feb951a42521104ff1d2657ce9fc77df99
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 27 20:53:55 2014 +0200
filters: ResizeLinearLF: Further optimalization
Optimize the inner loop further.
This reshuffles the multiplication and divisions saving a few
operations, which brings back the effectivity back as it was
before the precision fixes.
Signed-off-by: Cyril Hrubis <setan(a)ucw.cz>
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
index d7b57a06..6a2b947d 100644
--- a/libs/filters/GP_ResizeLinear.gen.c.t
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -50,20 +50,20 @@
for (x = 0; x < dst->w; x++) {
/* Get first left pixel */
%% for c in pt.chanslist
- uint32_t {{ c.name }}_tmp = {{ c.name }}[xmap[x]] * (MULT - xoff[x]) / DIV;
+ uint32_t {{ c.name }}_middle = 0;
+ uint32_t {{ c.name }}_first = {{ c.name }}[xmap[x]] * (MULT - xoff[x]);
%% endfor
/* Sum middle pixels */
for (j = xmap[x]+1; j < xmap[x+1]; j++) {
%% for c in pt.chanslist
- {{ c.name }}_tmp += {{ c.name }}[j] * MULT / DIV;
+ {{ c.name }}_middle += {{ c.name }}[j];
%% endfor
}
- /* Add last right pixel */
+ /* Add it all together with last pixel on the right */
%% for c in pt.chanslist
- {{ c.name }}_tmp += {{ c.name }}[xmap[x+1]] * xoff[x+1] / DIV;
-%% endfor
-%% for c in pt.chanslist
- {{ c.name }}_res[x] += {{ c.name }}_tmp * {{ mult }} / DIV;
+ {{ c.name }}_res[x] += ({{ c.name }}_middle * (MULT / DIV) +
+ ({{ c.name }}[xmap[x+1]] * xoff[x+1] +
+ {{ c.name }}_first) / DIV) * {{ mult }} / DIV;
%% endfor
}
%% endmacro
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_ResizeLinear.gen.c.t | 14 +++++++-------
1 files changed, 7 insertions(+), 7 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.")
1
0
25 May '14
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 0192d34fbb5325dc78143d0bb8438c6d2613aadd (commit)
via aba01e605969e8c5c6bfaee0759d1035522d47ef (commit)
from f0637e601e591b56c6b074a6ca7e51af29eb182d (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/0192d34fbb5325dc78143d0bb8438c6d2613…
commit 0192d34fbb5325dc78143d0bb8438c6d2613aadd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 25 22:06:06 2014 +0200
filters: ResizeLinearLF: Improve precision
Improves precision which fixes artefacts when downscaling from big image
to small image or with close to 1:1 ratio.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
index d0169df5..d7b57a06 100644
--- a/libs/filters/GP_ResizeLinear.gen.c.t
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -50,17 +50,20 @@
for (x = 0; x < dst->w; x++) {
/* Get first left pixel */
%% for c in pt.chanslist
- {{ c.name }}_res[x] += {{ c.name }}[xmap[x]] * (MULT - xoff[x]) * {{ mult }} / MULT;
+ uint32_t {{ c.name }}_tmp = {{ c.name }}[xmap[x]] * (MULT - xoff[x]) / DIV;
%% endfor
/* Sum middle pixels */
for (j = xmap[x]+1; j < xmap[x+1]; j++) {
%% for c in pt.chanslist
- {{ c.name }}_res[x] += {{ c.name }}[j] * {{ mult }};
+ {{ c.name }}_tmp += {{ c.name }}[j] * MULT / DIV;
%% endfor
}
/* Add last right pixel */
%% for c in pt.chanslist
- {{ c.name }}_res[x] += {{ c.name }}[xmap[x+1]] * xoff[x+1] * {{ mult }} / MULT;
+ {{ c.name }}_tmp += {{ c.name }}[xmap[x+1]] * xoff[x+1] / DIV;
+%% endfor
+%% for c in pt.chanslist
+ {{ c.name }}_res[x] += {{ c.name }}_tmp * {{ mult }} / DIV;
%% endfor
}
%% endmacro
@@ -73,8 +76,8 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
{
uint32_t xmap[dst->w + 1];
uint32_t ymap[dst->h + 1];
- uint16_t xoff[dst->w + 1];
- uint16_t yoff[dst->h + 1];
+ uint32_t xoff[dst->w + 1];
+ uint32_t yoff[dst->h + 1];
%% for c in pt.chanslist
uint32_t {{ c.name }}[src->w];
%% endfor
@@ -82,23 +85,26 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
uint32_t i, j;
{# Reduce fixed point bits for > 8 bits per channel (fixed 16 bit Grayscale) #}
%% if pt.chanslist[0].size > 8
- const int MULT=256;
+ const int MULT=1<<10;
+ const int DIV=1<<6;
%% else
- const int MULT=1024;
+ const int MULT=1<<14;
+ const int DIV=1<<9;
%% endif
+
/* Pre-compute mapping for interpolation */
for (i = 0; i <= dst->w; i++) {
- xmap[i] = (i * src->w) / dst->w;
- xoff[i] = (MULT * (i * src->w))/dst->w - MULT * xmap[i];
+ xmap[i] = ((uint64_t)i * src->w) / dst->w;
+ xoff[i] = ((uint64_t)MULT * (i * src->w))/dst->w - MULT * xmap[i];
}
for (i = 0; i <= dst->h; i++) {
- ymap[i] = (i * src->h) / dst->h;
- yoff[i] = (MULT * (i * src->h))/dst->h - MULT * ymap[i];
+ ymap[i] = ((uint64_t)i * src->h) / dst->h;
+ yoff[i] = ((uint64_t)MULT * (i * src->h))/dst->h - MULT * ymap[i];
}
/* Compute pixel area for the final normalization */
- uint32_t div = (xmap[1] * MULT + xoff[1]) * (ymap[1] * MULT + yoff[1]) / MULT;
+ uint32_t div = (((uint64_t)(xmap[1] * MULT + xoff[1]) * ((uint64_t)ymap[1] * MULT + yoff[1]) + DIV/2) / DIV + DIV/2)/DIV;
/* Prefetch first row */
{{ fetch_rows(pt, 0) }}
http://repo.or.cz/w/gfxprim.git/commit/aba01e605969e8c5c6bfaee0759d1035522d…
commit aba01e605969e8c5c6bfaee0759d1035522d47ef
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 25 16:21:51 2014 +0200
filters: ResizeLinearLF: More work
Removes useless if in inner cycle which brings another 10% speedup.
Do not fetch border rows twice about 20% speedup.
Get rid of the C macro, use jinja macro.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
index a7887907..d0169df5 100644
--- a/libs/filters/GP_ResizeLinear.gen.c.t
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -37,28 +37,33 @@
#include "GP_Resize.h"
-%%- macro fetch_row(pt, src, y, suff)
- {
- unsigned int x;
-
+%%- macro fetch_rows(pt, y)
for (x = 0; x < src->w; x++) {
- GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}({{ src }}, x, {{ y }});
+ GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x, {{ y }});
%% for c in pt.chanslist
- {{ c.name }}{{ suff }}[x] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
+ {{ c.name }}[x] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
%% endfor
}
- }
%% endmacro
-#define SUM(COL, COLD, MUL) - COLD[x] += (COL[xmap[x]] * (MULT - xoff[x]) * (MUL)) / MULT;-- for (j = xmap[x]+1; j < xmap[x+1]; j++) { - COLD[x] += (COL[j] * (MUL)); - } -- if (xoff[x+1]) - COLD[x] += (COL[xmap[x+1]] * xoff[x+1] * (MUL)) / MULT;
+%%- macro sum_rows(pt, mult)
+ for (x = 0; x < dst->w; x++) {
+ /* Get first left pixel */
+%% for c in pt.chanslist
+ {{ c.name }}_res[x] += {{ c.name }}[xmap[x]] * (MULT - xoff[x]) * {{ mult }} / MULT;
+%% endfor
+ /* Sum middle pixels */
+ for (j = xmap[x]+1; j < xmap[x+1]; j++) {
+%% for c in pt.chanslist
+ {{ c.name }}_res[x] += {{ c.name }}[j] * {{ mult }};
+%% endfor
+ }
+ /* Add last right pixel */
+%% for c in pt.chanslist
+ {{ c.name }}_res[x] += {{ c.name }}[xmap[x+1]] * xoff[x+1] * {{ mult }} / MULT;
+%% endfor
+ }
+%% endmacro
%% for pt in pixeltypes
%% if not pt.is_unknown() and not pt.is_palette()
@@ -70,6 +75,9 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
uint32_t ymap[dst->h + 1];
uint16_t xoff[dst->w + 1];
uint16_t yoff[dst->h + 1];
+%% for c in pt.chanslist
+ uint32_t {{ c.name }}[src->w];
+%% endfor
uint32_t x, y;
uint32_t i, j;
{# Reduce fixed point bits for > 8 bits per channel (fixed 16 bit Grayscale) #}
@@ -92,10 +100,12 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
/* Compute pixel area for the final normalization */
uint32_t div = (xmap[1] * MULT + xoff[1]) * (ymap[1] * MULT + yoff[1]) / MULT;
+ /* Prefetch first row */
+ {{ fetch_rows(pt, 0) }}
+
for (y = 0; y < dst->h; y++) {
%% for c in pt.chanslist
- uint32_t {{ c.name }}[src->w];
- uint32_t {{ c.name }}_res[src->w];
+ uint32_t {{ c.name }}_res[dst->w];
%% endfor
%% for c in pt.chanslist
@@ -103,31 +113,18 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
%% endfor
/* Sum first row */
- {{ fetch_row(pt, 'src', 'ymap[y]', '') }}
- for (x = 0; x < dst->w; x++) {
-%% for c in pt.chanslist
- SUM({{ c.name }}, {{ c.name }}_res, MULT-yoff[y]);
-%% endfor
- }
+ {{ sum_rows(pt, '(MULT-yoff[y])') }}
/* Sum middle */
for (i = ymap[y]+1; i < ymap[y+1]; i++) {
- {{ fetch_row(pt, 'src', 'i', '') }}
- for (x = 0; x < dst->w; x++) {
-%% for c in pt.chanslist
- SUM({{ c.name }}, {{ c.name }}_res, MULT);
-%% endfor
- }
+ {{ fetch_rows(pt, 'i') }}
+ {{ sum_rows(pt, 'MULT') }}
}
/* Sum last row */
if (yoff[y+1]) {
- {{ fetch_row(pt, 'src', 'ymap[y+1]', '') }}
- for (x = 0; x < dst->w; x++) {
-%% for c in pt.chanslist
- SUM({{ c.name }}, {{ c.name }}_res, yoff[y+1]);
-%% endfor
- }
+ {{ fetch_rows(pt, 'ymap[y+1]') }}
+ {{ sum_rows(pt, 'yoff[y+1]') }}
}
for (x = 0; x < dst->w; x++) {
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_ResizeLinear.gen.c.t | 93 +++++++++++++++++----------------
1 files changed, 48 insertions(+), 45 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.")
1
0
25 May '14
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 f0637e601e591b56c6b074a6ca7e51af29eb182d (commit)
from 0ccf9c3c0c8bc079bab8cefcbfeae1a3f5858f52 (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/f0637e601e591b56c6b074a6ca7e51af29eb…
commit f0637e601e591b56c6b074a6ca7e51af29eb182d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 25 15:29:35 2014 +0200
doc: Update gen.txt PixelChannel description
The PixelChannel is an object now (not a list).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/gen.txt b/doc/gen.txt
index 23edf2b8..ddb3082d 100644
--- a/doc/gen.txt
+++ b/doc/gen.txt
@@ -196,9 +196,25 @@ This object represents pixel type which describes the sizes and arrangements of
channels in a pixel. Note that it carries an instance of pixel size described
above.
-The chanslist is a list of triplets describing individual channels as
-[('chan_name', 'bit_offset', 'bit_size') ] where 'chan_name' is usually one of
-R, G, B, V (value, used for grayscale), A (opacity).
+[source,python]
+-------------------------------------------------------------------------------
+class PixelChannel():
+ # Index (position in pixel from left)
+ self.idx = idx
+ # Pixel channel name such as R, G, B, A, ...
+ self.name = name
+ # Bit offset in pixel
+ self.off = offset
+ # Channel bit size
+ self.size = size
+ # Maximal channel value
+ self.max = 2 ** size - 1
+ ...
+-------------------------------------------------------------------------------
+
+The chanslist describes pixel channel. There are some convenient members to be
+used directly from C code whose value is a hexadecimal string, i.e. 'C_mask',
+'C_max', 'C_shift'.
Templating language
~~~~~~~~~~~~~~~~~~~
-----------------------------------------------------------------------
Summary of changes:
doc/gen.txt | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 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.")
1
0
24 May '14
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 0ccf9c3c0c8bc079bab8cefcbfeae1a3f5858f52 (commit)
via d253cc6c27e58532a905323605011047c885b185 (commit)
from 72089793bd18d1bcb485401d7f97fabb82b08634 (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/0ccf9c3c0c8bc079bab8cefcbfeae1a3f585…
commit 0ccf9c3c0c8bc079bab8cefcbfeae1a3f5858f52
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 24 22:04:44 2014 +0200
filters: ResizeLinearLF: Rewrite.
Now faster, simpler and working for 16 bit Grayscale.
The code needs to be a cleaned a bit later though.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
index 958c01c6..a7887907 100644
--- a/libs/filters/GP_ResizeLinear.gen.c.t
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -26,6 +26,7 @@
%% block body
+#include <string.h>
#include <errno.h>
#include "core/GP_Context.h"
@@ -36,75 +37,32 @@
#include "GP_Resize.h"
-/*
- * Sample row.
- *
- * The x and y are starting coordinates in source image.
- *
- * The xpix_dist is distance of two sampled pixels in source image coordinates.
- *
- * The xoff is offset of the first pixel.
- */
-%%- macro sample_x(pt, suff)
-{
- uint32_t mx = x0;
- uint32_t i;
-
- pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
-
- %% for c in pt.chanslist
- {{ c[0] }}{{ suff }} = (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * xoff[x]) >> 9;
- %% endfor
-
- for (i = (1<<14) - xoff[x]; i > xpix_dist; i -= xpix_dist) {
- if (mx < src->w - 1)
- mx++;
-
- pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
-
- %% for c in pt.chanslist
- {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * xpix_dist) >> 9;
- %% endfor
- }
+%%- macro fetch_row(pt, src, y, suff)
+ {
+ unsigned int x;
- if (i > 0) {
- if (mx < src->w - 1)
- mx++;
-
- pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
-
- %% for c in pt.chanslist
- {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * i) >> 9;
- %% endfor
- }
+ for (x = 0; x < src->w; x++) {
+ GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}({{ src }}, x, {{ y }});
+%% for c in pt.chanslist
+ {{ c.name }}{{ suff }}[x] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
+%% endfor
+ }
}
%% endmacro
+#define SUM(COL, COLD, MUL) + COLD[x] += (COL[xmap[x]] * (MULT - xoff[x]) * (MUL)) / MULT;++ for (j = xmap[x]+1; j < xmap[x+1]; j++) { + COLD[x] += (COL[j] * (MUL)); + } ++ if (xoff[x+1]) + COLD[x] += (COL[xmap[x+1]] * xoff[x+1] * (MUL)) / MULT;
+
%% for pt in pixeltypes
%% if not pt.is_unknown() and not pt.is_palette()
-/*
- * Linear interpolation with low-pass filtering, used for fast downscaling
- * on both x and y.
- *
- * Basically we do weighted arithmetic mean of the pixels:
- *
- * [x, y], [x + 1, y], [x + 2, y] ... [x + k, y]
- * [x, y + 1]
- * [x, y + 2] .
- * . . .
- * . . .
- * . .
- * [x, y + l] .... [x + k, y + l]
- *
- *
- * The parameter k respectively l is determined by the distance between
- * sampled coordinates on x respectively y.
- *
- * The pixels are weighted by how much they are 'hit' by the rectangle defined
- * by the sampled pixel.
- *
- * The implementation is inspired by imlib2 downscaling algorithm.
- */
+
static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -114,78 +72,70 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
uint16_t yoff[dst->h + 1];
uint32_t x, y;
uint32_t i, j;
- GP_Pixel pix;
-
+{# Reduce fixed point bits for > 8 bits per channel (fixed 16 bit Grayscale) #}
+%% if pt.chanslist[0].size > 8
+ const int MULT=256;
+%% else
+ const int MULT=1024;
+%% endif
/* Pre-compute mapping for interpolation */
- uint32_t xstep = ((src->w - 1) << 16) / (dst->w - 1);
- uint32_t xpix_dist = ((dst->w - 1) << 14) / (src->w - 1);
-
- for (i = 0; i < dst->w + 1; i++) {
- uint32_t val = i * xstep;
- xmap[i] = val >> 16;
- xoff[i] = ((255 - ((val >> 8) & 0xff)) * xpix_dist)>>8;
+ for (i = 0; i <= dst->w; i++) {
+ xmap[i] = (i * src->w) / dst->w;
+ xoff[i] = (MULT * (i * src->w))/dst->w - MULT * xmap[i];
}
- uint32_t ystep = ((src->h - 1) << 16) / (dst->h - 1);
- uint32_t ypix_dist = ((dst->h - 1) << 14) / (src->h - 1);
-
- for (i = 0; i < dst->h + 1; i++) {
- uint32_t val = i * ystep;
- ymap[i] = val >> 16;
- yoff[i] = ((255 - ((val >> 8) & 0xff)) * ypix_dist)>>8;
+ for (i = 0; i <= dst->h; i++) {
+ ymap[i] = (i * src->h) / dst->h;
+ yoff[i] = (MULT * (i * src->h))/dst->h - MULT * ymap[i];
}
- /* Interpolate */
- for (y = 0; y < dst->h; y++) {
- for (x = 0; x < dst->w; x++) {
- %% for c in pt.chanslist
- uint32_t {{ c[0] }}, {{ c[0] }}1;
- %% endfor
+ /* Compute pixel area for the final normalization */
+ uint32_t div = (xmap[1] * MULT + xoff[1]) * (ymap[1] * MULT + yoff[1]) / MULT;
- uint32_t x0, y0;
-
- x0 = xmap[x];
- y0 = ymap[y];
-
- {{ sample_x(pt, '') }}
-
- %% for c in pt.chanslist
- {{ c[0] }} = ({{ c[0] }} * yoff[y]) >> 14;
- %% endfor
-
- for (j = (1<<14) - yoff[y]; j > ypix_dist; j -= ypix_dist) {
-
- x0 = xmap[x];
+ for (y = 0; y < dst->h; y++) {
+%% for c in pt.chanslist
+ uint32_t {{ c.name }}[src->w];
+ uint32_t {{ c.name }}_res[src->w];
+%% endfor
- if (y0 < src->h - 1)
- y0++;
+%% for c in pt.chanslist
+ memset({{ c.name }}_res, 0, sizeof({{ c.name }}_res));
+%% endfor
- {{ sample_x(pt, '1') }}
+ /* Sum first row */
+ {{ fetch_row(pt, 'src', 'ymap[y]', '') }}
+ for (x = 0; x < dst->w; x++) {
+%% for c in pt.chanslist
+ SUM({{ c.name }}, {{ c.name }}_res, MULT-yoff[y]);
+%% endfor
+ }
- %% for c in pt.chanslist
- {{ c[0] }} += ({{ c[0] }}1 * ypix_dist) >> 14;
- %% endfor
+ /* Sum middle */
+ for (i = ymap[y]+1; i < ymap[y+1]; i++) {
+ {{ fetch_row(pt, 'src', 'i', '') }}
+ for (x = 0; x < dst->w; x++) {
+%% for c in pt.chanslist
+ SUM({{ c.name }}, {{ c.name }}_res, MULT);
+%% endfor
}
+ }
- if (j > 0) {
- x0 = xmap[x];
-
- if (y0 < src->h - 1)
- y0++;
-
- {{ sample_x(pt, '1') }}
-
- %% for c in pt.chanslist
- {{ c[0] }} += ({{ c[0] }}1 * j) >> 14;
- %% endfor
+ /* Sum last row */
+ if (yoff[y+1]) {
+ {{ fetch_row(pt, 'src', 'ymap[y+1]', '') }}
+ for (x = 0; x < dst->w; x++) {
+%% for c in pt.chanslist
+ SUM({{ c.name }}, {{ c.name }}_res, yoff[y+1]);
+%% endfor
}
+ }
- %% for c in pt.chanslist
- {{ c[0] }} = ({{ c[0] }} + (1<<4))>>5;
- %% endfor
-
- GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y,
- GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "") }}));
+ for (x = 0; x < dst->w; x++) {
+%% for c in pt.chanslist
+ uint32_t {{ c.name }}_p = ({{ c.name }}_res[x] + div/2) / div;
+%% endfor
+ GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y,
+ GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, '', '_p') }}));
}
if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
@@ -195,6 +145,7 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallbackDone(callback);
return 0;
}
+
%% endif
%% endfor
@@ -228,7 +179,7 @@ static int resize_lin{{ pt.name }}(const GP_Context *src, GP_Context *dst,
for (i = 0; i < dst->h + 1; i++) {
uint32_t val = i * ystep;
ymap[i] = val >> 16;
- yoff[i] = (val >> 8) & 0xff;
+ yoff[i] = (val >> 8) & 0xff;
}
/* Interpolate */
@@ -296,13 +247,13 @@ static int resize_lin(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
switch (src->pixel_type) {
- %% for pt in pixeltypes
- %% if not pt.is_unknown() and not pt.is_palette()
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_palette()
case GP_PIXEL_{{ pt.name }}:
return resize_lin{{ pt.name }}(src, dst, callback);
break;
- %% endif
- %% endfor
+%% endif
+%% endfor
default:
GP_WARN("Invalid pixel type %s",
GP_PixelTypeName(src->pixel_type));
@@ -323,7 +274,7 @@ int GP_FilterResizeLinearInt(const GP_Context *src, GP_Context *dst,
return resize_lin(src, dst, callback);
}
-static int resize_lin_lf2(const GP_Context *src, GP_Context *dst,
+static int resize_lin_lf(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
float x_rat = 1.00 * dst->w / src->w;
@@ -335,14 +286,17 @@ static int resize_lin_lf2(const GP_Context *src, GP_Context *dst,
src->w, src->h, dst->w, dst->h, x_rat, y_rat);
switch (src->pixel_type) {
- %% for pt in pixeltypes
- %% if not pt.is_unknown() and not pt.is_palette()
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_palette()
case GP_PIXEL_{{ pt.name }}:
return resize_lin_lf_{{ pt.name }}(src, dst, callback);
break;
- %% endif
- %% endfor
+%% endif
+%% endfor
default:
+ GP_WARN("Invalid pixel type %s",
+ GP_PixelTypeName(src->pixel_type));
+ errno = EINVAL;
return -1;
}
}
@@ -362,7 +316,7 @@ int GP_FilterResizeLinearLFInt(const GP_Context *src, GP_Context *dst,
return 1;
}
- return resize_lin_lf2(src, dst, callback);
+ return resize_lin_lf(src, dst, callback);
}
%% endblock body
http://repo.or.cz/w/gfxprim.git/commit/d253cc6c27e58532a905323605011047c885…
commit d253cc6c27e58532a905323605011047c885b185
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 17 22:25:26 2014 +0200
loaders: JPG: Remove stub for removed function.
Remove GP_OpenJPG() stub for removed function.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index e45b23c4..6fd5dd28 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -557,12 +557,6 @@ int GP_MatchJPG(const void GP_UNUSED(*buf))
return -1;
}
-int GP_OpenJPG(const char GP_UNUSED(*src_path), FILE GP_UNUSED(**f))
-{
- errno = ENOSYS;
- return 1;
-}
-
GP_Context *GP_ReadJPG(GP_IO GP_UNUSED(*io),
GP_ProgressCallback GP_UNUSED(*callback))
{
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_ResizeLinear.gen.c.t | 222 +++++++++++++--------------------
libs/loaders/GP_JPG.c | 6 -
2 files changed, 88 insertions(+), 140 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.")
1
0