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
17 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 72089793bd18d1bcb485401d7f97fabb82b08634 (commit)
from dbd7368023249233216d3c6ce873213833f64940 (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/72089793bd18d1bcb485401d7f97fabb82b0…
commit 72089793bd18d1bcb485401d7f97fabb82b08634
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 17 22:15:45 2014 +0200
loaders: Convert MetaData loaders to GP_IO
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h
index 95123ecd..93cd2df2 100644
--- a/include/loaders/GP_JPG.h
+++ b/include/loaders/GP_JPG.h
@@ -50,7 +50,7 @@ GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback);
/*
* Loads JPEG meta-data, called markers in JPEG terminology.
*/
-int GP_ReadJPGMetaData(FILE *f, GP_MetaData *data);
+int GP_ReadJPGMetaData(GP_IO *io, GP_MetaData *data);
int GP_LoadJPGMetaData(const char *src_path, GP_MetaData *data);
/*
diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h
index 0b440d06..b99e7280 100644
--- a/include/loaders/GP_PNG.h
+++ b/include/loaders/GP_PNG.h
@@ -48,9 +48,9 @@ GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback);
GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback);
/*
- * Loads png meta-data.
+ * Loads PNG meta-data.
*/
-int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data);
+int GP_ReadPNGMetaData(GP_IO *io, GP_MetaData *data);
int GP_LoadPNGMetaData(const char *src_path, GP_MetaData *data);
/*
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index da4cf48f..e45b23c4 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -184,13 +184,28 @@ static void skip_input_data(struct jpeg_decompress_struct *cinfo, long num_bytes
}
}
+static inline void init_source_mgr(struct my_source_mgr *src, GP_IO *io,
+ void *buf, size_t buf_size)
+{
+ src->mgr.init_source = dummy;
+ src->mgr.resync_to_restart = jpeg_resync_to_restart;
+ src->mgr.term_source = dummy;
+ src->mgr.fill_input_buffer = fill_input_buffer;
+ src->mgr.skip_input_data = skip_input_data;
+ src->mgr.bytes_in_buffer = 0;
+ src->mgr.next_input_byte = NULL;
+ src->io = io;
+ src->buffer = buf;
+ src->size = buf_size;
+}
+
GP_Context *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback)
{
struct jpeg_decompress_struct cinfo;
struct my_source_mgr src;
struct my_jpg_err my_err;
GP_Context *ret = NULL;
- uint8_t buffer[1024];
+ uint8_t buf[1024];
int err;
cinfo.err = jpeg_std_error(&my_err.error_mgr);
@@ -202,18 +217,7 @@ GP_Context *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback)
}
jpeg_create_decompress(&cinfo);
-
- /* Initialize custom source manager */
- src.mgr.init_source = dummy;
- src.mgr.resync_to_restart = jpeg_resync_to_restart;
- src.mgr.term_source = dummy;
- src.mgr.fill_input_buffer = fill_input_buffer;
- src.mgr.skip_input_data = skip_input_data;
- src.mgr.bytes_in_buffer = 0;
- src.mgr.next_input_byte = NULL;
- src.io = io;
- src.buffer = buffer;
- src.size = sizeof(buffer);
+ init_source_mgr(&src, io, buf, sizeof(buf));
cinfo.src = (void*)&src;
jpeg_read_header(&cinfo, TRUE);
@@ -340,10 +344,12 @@ static void save_jpg_markers(struct jpeg_decompress_struct *cinfo)
jpeg_save_markers(cinfo, JPEG_APP0 + 1, 0xffff);
}
-int GP_ReadJPGMetaData(FILE *f, GP_MetaData *data)
+int GP_ReadJPGMetaData(GP_IO *io, GP_MetaData *data)
{
struct jpeg_decompress_struct cinfo;
+ struct my_source_mgr src;
struct my_jpg_err my_err;
+ uint8_t buf[1024];
int err;
cinfo.err = jpeg_std_error(&my_err.error_mgr);
@@ -355,7 +361,8 @@ int GP_ReadJPGMetaData(FILE *f, GP_MetaData *data)
}
jpeg_create_decompress(&cinfo);
- jpeg_stdio_src(&cinfo, f);
+ init_source_mgr(&src, io, buf, sizeof(buf));
+ cinfo.src = (void*)&src;
save_jpg_markers(&cinfo);
@@ -380,15 +387,18 @@ err1:
int GP_LoadJPGMetaData(const char *src_path, GP_MetaData *data)
{
- //FILE *f;
- int ret = -1;
+ GP_IO *io;
+ int err, ret;
- //if (GP_OpenJPG(src_path, &f))
- // return 1;
+ io = GP_IOFile(src_path, GP_IO_RDONLY);
+ if (!io)
+ return 1;
- //ret = GP_ReadJPGMetaData(f, data);
+ ret = GP_ReadJPGMetaData(io, data);
- //fclose(f);
+ err = errno;
+ GP_IOClose(io);
+ errno = err;
return ret;
}
@@ -567,7 +577,7 @@ GP_Context *GP_LoadJPG(const char GP_UNUSED(*src_path),
return NULL;
}
-int GP_ReadJPGMetaData(FILE GP_UNUSED(*f), GP_MetaData GP_UNUSED(*data))
+int GP_ReadJPGMetaData(GP_IO GP_UNUSED(*io), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
return 1;
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 0ea37379..50f5fcdf 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -103,7 +103,6 @@ GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback)
goto err2;
}
- //png_init_io(png, f);
png_set_read_fn(png, io, read_data);
png_set_sig_bytes(png, 0);
png_read_info(png, png_info);
@@ -345,7 +344,7 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat
}
}
-int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data)
+int GP_ReadPNGMetaData(GP_IO *io, GP_MetaData *data)
{
png_structp png;
png_infop png_info = NULL;
@@ -374,8 +373,8 @@ int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data)
goto err2;
}
- png_init_io(png, f);
- png_set_sig_bytes(png, 8);
+ png_set_read_fn(png, io, read_data);
+ png_set_sig_bytes(png, 0);
png_read_info(png, png_info);
load_meta_data(png, png_info, data);
@@ -390,15 +389,18 @@ err1:
int GP_LoadPNGMetaData(const char *src_path, GP_MetaData *data)
{
- FILE *f;
- int ret;
+ GP_IO *io;
+ int ret, err;
-// if (GP_OpenPNG(src_path, &f))
-// return 1;
+ io = GP_IOFile(src_path, GP_IO_RDONLY);
+ if (!io)
+ return 1;
- ret = GP_ReadPNGMetaData(f, data);
+ ret = GP_ReadPNGMetaData(io, data);
- fclose(f);
+ err = errno;
+ GP_IOClose(io);
+ errno = err;
return ret;
}
@@ -630,7 +632,7 @@ GP_Context *GP_LoadPNG(const char GP_UNUSED(*src_path),
return NULL;
}
-int GP_ReadPNGMetaData(FILE GP_UNUSED(*f), GP_MetaData GP_UNUSED(*data))
+int GP_ReadPNGMetaData(GP_IO GP_UNUSED(*io), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
return 1;
-----------------------------------------------------------------------
Summary of changes:
include/loaders/GP_JPG.h | 2 +-
include/loaders/GP_PNG.h | 4 +-
libs/loaders/GP_JPG.c | 54 +++++++++++++++++++++++++++------------------
libs/loaders/GP_PNG.c | 24 +++++++++++---------
4 files changed, 48 insertions(+), 36 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
17 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 dbd7368023249233216d3c6ce873213833f64940 (commit)
via d64d59ffe85c39cc5f1f285226dd75493d236a00 (commit)
via 839f3e4ae66a2068ff6059fd14502e6120418c3e (commit)
via 77ef6dd38134300845793ff4da8d4ff6aeaa85bd (commit)
from b751bfc9b78d8dc25a503efce8582a8f6df10af7 (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/dbd7368023249233216d3c6ce873213833f6…
commit dbd7368023249233216d3c6ce873213833f64940
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 17 21:11:00 2014 +0200
core: MixPixels: Change RGB mix to linear.
Do not use Gamma mixing, this fixes font rendering.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_MixPixels.gen.h.t b/include/core/GP_MixPixels.gen.h.t
index 8067f4be..7333fe9f 100644
--- a/include/core/GP_MixPixels.gen.h.t
+++ b/include/core/GP_MixPixels.gen.h.t
@@ -75,7 +75,7 @@ Macros to mix two pixels accordingly to percentage.
#define GP_MIX_PIXELS_{{ pt.name }}(pix1, pix2, perc) %% if pt.is_rgb()
- GP_MIX_PIXELS_GAMMA_{{ pt.name }}(pix1, pix2, perc)
+ GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc)
%% else
GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc)
%% endif
http://repo.or.cz/w/gfxprim.git/commit/d64d59ffe85c39cc5f1f285226dd75493d23…
commit d64d59ffe85c39cc5f1f285226dd75493d236a00
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 17 21:09:03 2014 +0200
text: GP_Font.c: Remove useless includes.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c
index 62a1efd9..ff5f5c20 100644
--- a/libs/text/GP_Font.c
+++ b/libs/text/GP_Font.c
@@ -16,12 +16,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_MixPixels.gen.h"
+#include <stdlib.h>
#include "GP_Font.h"
#include "GP_DefaultFont.h"
http://repo.or.cz/w/gfxprim.git/commit/839f3e4ae66a2068ff6059fd14502e612041…
commit 839f3e4ae66a2068ff6059fd14502e6120418c3e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 17 19:56:39 2014 +0200
spiv: Add support for TTF font
Adds two config options for TTF font path and font height.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.1 b/demos/spiv/spiv.1
index 30bd5d9f..69297e20 100644
--- a/demos/spiv/spiv.1
+++ b/demos/spiv/spiv.1
@@ -105,6 +105,12 @@ Shows this help
.B -i, --show-info
Show image info such as filename, size, etc...
.TP
+.B --font-path=value
+Path to TTF font to be used in GUI
+.TP
+.B --font-height=value
+TTF font height in pixels
+.TP
.B -p, --show-progress
Show progress bar when loading/resampling/... images
.TP
@@ -178,6 +184,12 @@ by [NameSpace] and continues until next namespace.
.B ShowInfo
Show image info such as filename, size, etc...
.TP
+.B FontPath=value
+Path to TTF font to be used in GUI
+.TP
+.B FontHeight=value
+TTF font height in pixels
+.TP
.B ShowProgress
Show progress bar when loading/resampling/... images
.TP
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index d4785e0a..3cf212c3 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -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> *
* *
*****************************************************************************/
@@ -96,17 +96,17 @@ static int image_loader_callback(GP_ProgressCallback *self)
int align = GP_ALIGN_CENTER|GP_VALIGN_ABOVE;
- size = GP_TextWidth(NULL, buf);
+ size = GP_TextWidth(config.style, buf);
int start = c->w/2 - size/2 - 10;
int end = c->w/2 + size/2 + 10;
int middle = start + (end - start) * self->percentage / 100;
- int top = c->h - GP_TextHeight(NULL) - 11;
+ int top = c->h - GP_TextHeight(config.style) - 11;
GP_FillRectXYXY(c, start, c->h - 1, middle, top, gray_pixel);
GP_FillRectXYXY(c, middle, c->h - 1, end, top, black_pixel);
- GP_Text(c, NULL, c->w/2, c->h - 5, align,
+ GP_Text(c, config.style, c->w/2, c->h - 5, align,
white_pixel, black_pixel, buf);
GP_BackendUpdateRect(backend, start, c->h - 1, end, top);
@@ -154,10 +154,10 @@ static GP_Context *load_image(int elevate)
GP_Context *ctx = backend->context;
GP_Fill(ctx, black_pixel);
- GP_Print(ctx, NULL, ctx->w/2, ctx->h/2 - 10,
+ GP_Print(ctx, config.style, ctx->w/2, ctx->h/2 - 10,
GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel,
"'%s'", image_loader_img_path());
- GP_Print(ctx, NULL, ctx->w/2, ctx->h/2 + 10,
+ GP_Print(ctx, config.style, ctx->w/2, ctx->h/2 + 10,
GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel,
"Failed to load image :( (%s)", strerror(errno));
GP_BackendFlip(backend);
@@ -203,11 +203,11 @@ static void info_printf(GP_Context *ctx, GP_Coord x, GP_Coord y,
va_start(va, fmt);
va_copy(vac, va);
- GP_VPrint(ctx, NULL, x-1, y-1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ GP_VPrint(ctx, config.style, x-1, y-1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM|GP_TEXT_NOBG,
black_pixel, white_pixel, fmt, vac);
va_end(vac);
- GP_VPrint(ctx, NULL, x, y, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ GP_VPrint(ctx, config.style, x, y, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM|GP_TEXT_NOBG,
white_pixel, black_pixel, fmt, va);
va_end(va);
@@ -224,7 +224,7 @@ static void show_info(struct loader_params *params, GP_Context *img,
if (!config.show_info)
return;
- GP_Size th = GP_TextHeight(NULL), y = 10;
+ GP_Size th = GP_TextHeight(config.style), y = 10;
info_printf(context, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%% %s",
img->w, img->h, orig_img->w, orig_img->h, params->zoom_rat,
diff --git a/demos/spiv/spiv_config.c b/demos/spiv/spiv_config.c
index 166a28c5..6fa95f4b 100644
--- a/demos/spiv/spiv_config.c
+++ b/demos/spiv/spiv_config.c
@@ -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> *
* *
*****************************************************************************/
@@ -41,6 +41,9 @@ struct spiv_config config = {
.full_screen = 0,
.max_win_w = 1024,
.max_win_h = 768,
+
+ .font_path = NULL,
+ .font_height = 12,
};
static int set_zoom_strategy(struct cfg_opt *self, unsigned int lineno)
@@ -200,6 +203,60 @@ static int set_emulation(struct cfg_opt *self, unsigned int lineno)
return 0;
}
+int load_font_face(GP_TextStyle *style, const char *path, unsigned int height,
+ unsigned int lineno)
+{
+ GP_FontFace *font;
+ static GP_FontFace *old_font = NULL;
+
+ font = GP_FontFaceLoad(path, 0, height);
+
+ if (!font) {
+ fprintf(stderr, "ERROR: %u: Failed to load font '%s'n",
+ lineno, path);
+ return 1;
+ }
+
+ GP_FontFaceFree(old_font);
+ style->font = old_font = font;
+
+ return 0;
+}
+
+static int set_font(struct cfg_opt *self, unsigned int lineno)
+{
+ static GP_TextStyle style = {NULL, 0, 0, 1, 1, 0};
+
+ if (load_font_face(&style, self->val, config.font_height, lineno))
+ return 1;
+
+ free(config.font_path);
+ config.font_path = strdup(self->val);
+ config.style = &style;
+
+ return 0;
+}
+
+static int set_font_height(struct cfg_opt *self, unsigned int lineno)
+{
+ int height = atoi(self->val);
+
+ if (height <= 0) {
+ fprintf(stderr, "ERROR: %u: Wrong font height '%s'n",
+ lineno, self->val);
+ return 1;
+ }
+
+ config.font_height = height;
+
+ if (config.style) {
+ return load_font_face(config.style, config.font_path,
+ config.font_height, lineno);
+ }
+
+ return 0;
+}
+
static int help(struct cfg_opt *self, unsigned int lineno)
{
(void) self;
@@ -237,6 +294,20 @@ struct cfg_opt spiv_opts[] = {
.help = "Show image info such as filename, size, etc...",
},
{.name_space = "Gui",
+ .key = "FontPath",
+ .opt_long = "font-path",
+ .opt_has_value = 1,
+ .set = set_font,
+ .help = "Path to TTF font to be used in GUI",
+ },
+ {.name_space = "Gui",
+ .key = "FontHeight",
+ .opt_long = "font-height",
+ .opt_has_value = 1,
+ .set = set_font_height,
+ .help = "TTF font height in pixels",
+ },
+ {.name_space = "Gui",
.key = "ShowProgress",
.opt = 'p',
.opt_long = "show-progress",
diff --git a/demos/spiv/spiv_config.h b/demos/spiv/spiv_config.h
index e4a5c124..144ec6ea 100644
--- a/demos/spiv/spiv_config.h
+++ b/demos/spiv/spiv_config.h
@@ -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> *
* *
*****************************************************************************/
@@ -60,6 +60,11 @@ struct spiv_config {
int full_screen:1;
char backend_init[128];
GP_PixelType emul_type;
+
+ /* Font information */
+ GP_TextStyle *style;
+ char *font_path;
+ unsigned int font_height;
};
extern struct spiv_config config;
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index 9d018872..ef1f0c58 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -230,6 +230,8 @@ void print_man(void)
puts(man_tail);
}
+static int last_line;
+
static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff)
{
GP_Context *c = backend->context;
@@ -237,19 +239,32 @@ static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff)
GP_Pixel white = GP_ColorToContextPixel(GP_COL_WHITE, c);
int i;
+ int spacing = GP_TextHeight(config.style)/10 + 2;
+ int height = GP_TextHeight(config.style);
+
GP_Fill(c, black);
- GP_Print(c, NULL, 20 + 10 * xoff, 2, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ GP_Print(c, config.style, 20 + 10 * xoff, 2, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white, black, "%s", "Keyboard Controls:");
+ unsigned int max = 0;
+
+ for (i = 0; i < help_keys_len; i++)
+ max = GP_MAX(max, GP_TextWidth(config.style, help_keys[i].keys));
+
for (i = loff; i < help_keys_len; i++) {
- GP_Coord h = 2 + (i - loff + 1) * 15;
+ GP_Coord h = spacing + (i - loff + 1) * (height + spacing);
- if (h + 2 >= (GP_Coord)c->h)
+ if (h + height + spacing > (GP_Coord)c->h) {
+ last_line = 0;
goto out;
+ }
- GP_Print(c, NULL, 20 + 10 * xoff, h, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white, black, "%-"KEYS_MAX"s - %s", help_keys[i].keys, help_keys[i].desc);
+ GP_Print(c, config.style, 20 + 10 * xoff, h, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ white, black, "%s", help_keys[i].keys);
+ GP_Print(c, config.style, 20 + 10 * xoff + max, h, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ white, black, " - %s", help_keys[i].desc);
+ last_line = 1;
}
out:
@@ -257,11 +272,6 @@ out:
return i;
}
-static int max_lines(GP_Backend *backend)
-{
- return (backend->context->h - 4) / 15;
-}
-
void draw_help(GP_Backend *backend)
{
int loff = 0, last, xoff = 0;
@@ -294,17 +304,16 @@ void draw_help(GP_Backend *backend)
break;
case GP_KEY_PAGE_DOWN:
if (last < help_keys_len) {
- if (loff + max_lines(backend) >= help_keys_len)
+ if (last_line)
break;
- loff += max_lines(backend);
-
+ loff += last - loff;
last = redraw_help(backend, loff, xoff);
}
break;
case GP_KEY_PAGE_UP:
if (loff > 0) {
- loff -= max_lines(backend);
+ loff -= last - loff;
if (loff < 0)
loff = 0;
last = redraw_help(backend, loff, xoff);
http://repo.or.cz/w/gfxprim.git/commit/77ef6dd38134300845793ff4da8d4ff6aeaa…
commit 77ef6dd38134300845793ff4da8d4ff6aeaa85bd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 17 19:52:33 2014 +0200
text: GP_FontFaceFree(): Do not SegFault on NULL
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/text.txt b/doc/text.txt
index 3f3a5e70..8a4a4cb4 100644
--- a/doc/text.txt
+++ b/doc/text.txt
@@ -218,8 +218,9 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height);
void GP_FontFaceFree(GP_FontFace *self);
--------------------------------------------------------------------------------
-Renders TrueType font using link:http://www.freetype.org[FreeType] (currently
-printable ASCII only) into GFXprim font structures.
+The 'GP_FontFaceLoad()' renders TrueType font using
+link:http://www.freetype.org[FreeType] (currently printable ASCII only) into
+GFXprim font structures.
One of the 'width' or 'height' may be zero, which means that the second value
should be computed accordingly.
@@ -227,5 +228,7 @@ should be computed accordingly.
NOTE: If you pass both 'width' and 'height' non-zero the resulting font may
look strange as this action forced unnatural aspect ratio.
+The 'GP_FontFaceFree()' frees memory taken up by the rendered font. If self is
+NULL no operation is done.
TIP: For Font and TextStyle handling see link:example_fonts.html[examples].
diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c
index d7232393..62a1efd9 100644
--- a/libs/text/GP_Font.c
+++ b/libs/text/GP_Font.c
@@ -63,6 +63,9 @@ GP_GlyphBitmap *GP_GetGlyphBitmap(const GP_FontFace *font, int c)
void GP_FontFaceFree(GP_FontFace *self)
{
+ if (!self)
+ return;
+
free(self->glyphs);
free(self);
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.1 | 12 ++++++
demos/spiv/spiv.c | 18 +++++-----
demos/spiv/spiv_config.c | 73 ++++++++++++++++++++++++++++++++++++-
demos/spiv/spiv_config.h | 7 +++-
demos/spiv/spiv_help.c | 37 ++++++++++++-------
doc/text.txt | 7 +++-
include/core/GP_MixPixels.gen.h.t | 2 +-
libs/text/GP_Font.c | 8 +++--
8 files changed, 133 insertions(+), 31 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
11 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 b751bfc9b78d8dc25a503efce8582a8f6df10af7 (commit)
via 1479708a43cb28eada03dbf962fe98a623cd68d6 (commit)
from 76f73128753ed19cefe7e80e55520edccbb01b9a (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/b751bfc9b78d8dc25a503efce8582a8f6df1…
commit b751bfc9b78d8dc25a503efce8582a8f6df10af7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 11 14:06:56 2014 +0200
doc: Add resize filters to python docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/py_simple/resize.py b/demos/py_simple/resize.py
index 38a5b783..7d11e229 100755
--- a/demos/py_simple/resize.py
+++ b/demos/py_simple/resize.py
@@ -10,13 +10,10 @@ def main():
print("USAGE: %s imput_image output_image" % sys.argv[0]);
sys.exit(1)
- # Turns on debug messages
- core.SetDebugLevel(10);
-
# Load Image
src = loaders.Load(sys.argv[1])
# Resize image to the half of the original
- res = src.filters.ResizeAlloc(src.w//2, src.h//2, 2)
+ res = src.filters.ResizeLFIntAlloc(src.w//2, src.h//2)
# Save Image
res.loaders.Save(sys.argv[2])
diff --git a/doc/example_py_resize.txt b/doc/example_py_resize.txt
new file mode 100644
index 00000000..06504964
--- /dev/null
+++ b/doc/example_py_resize.txt
@@ -0,0 +1,8 @@
+Resize
+------
+A simple program that loads image, resizes it to half and saves result.
+
+[source,python]
+------------------------------------------------------------------
+include::../demos/py_simple/resize.py[]
+------------------------------------------------------------------
diff --git a/doc/filters_python.txt b/doc/filters_python.txt
index c1dadb84..fc202fbb 100644
--- a/doc/filters_python.txt
+++ b/doc/filters_python.txt
@@ -8,9 +8,10 @@ The filter functions could be called directly as +filters.Foo(img, ..)+ or
from submodule as +img.filters.Foo(..)+. Note that in the second case the
image is passed automatically as a first parameter.
-If filter has been aborted from callback 'OSError' with errno set to
-'ECANCELED' is raised, see progress callback
-link:core_python.html#Progress_Callback[documentation] for more information.
+If filter is aborted from a callback 'OSError' with errno set to
+'ECANCELED' is raised, see
+link:core_python.html#Progress_Callback[progress callback] for more
+information.
Point Filters
~~~~~~~~~~~~~
@@ -402,3 +403,29 @@ respectively y pixel neighbors from each side so the result is median of
rectangle of +2 * x + 1+ x +2 * y + 1+ pixels.
include::images/median/images.txt[]
+
+Resize
+~~~~~~
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Nearest neighbour resize, fastest but lowest quality
+ res = img.ResizeNNAlloc(100, 100, callback=None)
+
+ # Fast and good quality with low pass on downscaling
+ res = img.ResizeLinearLFIntAlloc(100, 100, callback=None)
+
+ # Cubic interpolation, needs low pass (blur) applied before downscaling
+ res = img.ResizeCubicIntAlloc(100, 100, callback=None)
+
+ # All of the above, TYPE is numeric enum
+ res = img.ResizeAlloc(100, 100, TYPE, callback=None)
+
+-------------------------------------------------------------------------------
+
+Functions to resize (resample) image.
+
+TIP: See link:example_py_resize.html[resize example].
http://repo.or.cz/w/gfxprim.git/commit/1479708a43cb28eada03dbf962fe98a623cd…
commit 1479708a43cb28eada03dbf962fe98a623cd68d6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 11 14:00:20 2014 +0200
pywrap: filters: Add ResizeCubicInt
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index a504f76a..3aeba03b 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -92,6 +92,10 @@ FILTER_FUNC(ResizeLinearInt);
FILTER_FUNC(ResizeLinearLFInt);
%include "GP_ResizeLinear.h"
+FILTER_FUNC(ResizeCubic);
+FILTER_FUNC(ResizeCubicInt);
+%include "GP_ResizeCubic.h"
+
/* Ditherings */
FILTER_FUNC(FloydSteinberg);
FILTER_FUNC(GP_FilterHilbertPeano);
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/resize.py | 5 +--
...mple_py_showimage.txt => example_py_resize.txt} | 8 ++--
doc/filters_python.txt | 33 ++++++++++++++++++--
pylib/gfxprim/filters/filters.i | 4 ++
4 files changed, 39 insertions(+), 11 deletions(-)
copy doc/{example_py_showimage.txt => example_py_resize.txt} (53%)
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 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 76f73128753ed19cefe7e80e55520edccbb01b9a (commit)
via ade7565f6c0e487071582b09196ac36c7fa1e4cf (commit)
from 93832f616ef3ea2dde888cf8e0b7e1a2da077d06 (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/76f73128753ed19cefe7e80e55520edccbb0…
commit 76f73128753ed19cefe7e80e55520edccbb01b9a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 10 14:50:37 2014 +0200
loaders: JPG: Fix segfault in load_cmyk()
Fixes typo in number of scanlines to load from a CMYK jpeg.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index a0eabd97..da4cf48f 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -113,7 +113,7 @@ static int load_cmyk(struct jpeg_decompress_struct *cinfo, GP_Context *ret,
uint32_t y = cinfo->output_scanline;
JSAMPROW addr = (void*)GP_PIXEL_ADDR(ret, 0, y);
- jpeg_read_scanlines(cinfo, &addr, 4);
+ jpeg_read_scanlines(cinfo, &addr, 1);
unsigned int i;
uint8_t *buf = GP_PIXEL_ADDR(ret, 0, y);
http://repo.or.cz/w/gfxprim.git/commit/ade7565f6c0e487071582b09196ac36c7fa1…
commit ade7565f6c0e487071582b09196ac36c7fa1e4cf
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 10 14:49:53 2014 +0200
tests: loaders: Add jpeg CMYK loader test.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/loaders/.gitignore b/tests/loaders/.gitignore
index f6863aaf..3ef73f19 100644
--- a/tests/loaders/.gitignore
+++ b/tests/loaders/.gitignore
@@ -6,6 +6,7 @@ PNG
PNM
PPM
PCX
+JPG
SaveAbort.gen
SaveLoad.gen
ZIP
diff --git a/tests/loaders/JPG.c b/tests/loaders/JPG.c
new file mode 100644
index 00000000..67c34dd4
--- /dev/null
+++ b/tests/loaders/JPG.c
@@ -0,0 +1,141 @@
+/*****************************************************************************
+ * 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 <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <core/GP_GetPutPixel.h>
+#include <loaders/GP_Loaders.h>
+
+#include "tst_test.h"
+
+static int test_load_JPG(const char *path)
+{
+ GP_Context *img;
+
+ errno = 0;
+
+ img = GP_LoadJPG(path, NULL);
+
+ if (img == NULL) {
+ switch (errno) {
+ case ENOSYS:
+ tst_msg("Not Implemented");
+ return TST_SKIPPED;
+ default:
+ tst_msg("Got %s", strerror(errno));
+ return TST_FAILED;
+ }
+ }
+
+ /*
+ * TODO: check correct data.
+ */
+
+ GP_ContextFree(img);
+
+ return TST_SUCCESS;
+}
+
+static int test_save_JPG(GP_PixelType pixel_type)
+{
+ GP_Context *ctx;
+ int ret;
+
+ ctx = GP_ContextAlloc(100, 100, pixel_type);
+
+ if (ctx == NULL) {
+ tst_msg("Failed to allocate context");
+ return TST_UNTESTED;
+ }
+
+ errno = 0;
+
+ ret = GP_SaveJPG(ctx, "/dev/null", NULL);
+
+ if (ret == 0) {
+ tst_msg("Saved successfully");
+ GP_ContextFree(ctx);
+ return TST_SUCCESS;
+ }
+
+ switch (errno) {
+ case ENOSYS:
+ tst_msg("Not Implemented");
+ GP_ContextFree(ctx);
+ return TST_SKIPPED;
+ default:
+ tst_msg("Failed and errno is not ENOSYS (%i)", errno);
+ GP_ContextFree(ctx);
+ return TST_FAILED;
+ }
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "JPEG",
+ .tests = {
+ /* JPEG loader tests */
+ {.name = "JPEG Load 100x100 CMYK",
+ .tst_fn = test_load_JPG,
+ .res_path = "data/jpeg/valid/100x100-cmyk-red.jpeg",
+ .data = "100x100-cmyk-red.jpeg",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "JPEG Load 100x100 RGB",
+ .tst_fn = test_load_JPG,
+ .res_path = "data/jpeg/valid/100x100-red.jpeg",
+ .data = "100x100-red.jpeg",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "JPEG Load 100x100 G8",
+ .tst_fn = test_load_JPG,
+ .res_path = "data/jpeg/valid/100x100-grayscale-white.jpeg",
+ .data = "100x100-grayscale-white.jpeg",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "JPEG Load 100x100 G8",
+ .tst_fn = test_load_JPG,
+ .res_path = "data/jpeg/valid/100x100-grayscale-black.jpeg",
+ .data = "100x100-grayscale-black.jpeg",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ /* JPEG save tests */
+ {.name = "JPEG Save 100x100 G8",
+ .tst_fn = test_save_JPG,
+ .data = (void*)GP_PIXEL_G8,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "JPEG Save 100x100 RGB888",
+ .tst_fn = test_save_JPG,
+ .data = (void*)GP_PIXEL_RGB888,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "JPEG Save 100x100 BGR888",
+ .tst_fn = test_save_JPG,
+ .data = (void*)GP_PIXEL_BGR888,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = NULL},
+ }
+};
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index 890e5761..fb56086d 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -1,11 +1,12 @@
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
+CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c ZIP.c GIF.c IO.c PNM.c PCX.c+ JPG.c
GENSOURCES=SaveLoad.gen.c SaveAbort.gen.c
APPS=loaders_suite PNG PBM PGM PPM PNM SaveLoad.gen SaveAbort.gen ZIP GIF PCX- IO
+ IO JPG
include ../tests.mk
diff --git a/tests/loaders/data/jpeg/valid/100x100-cmyk-red.jpeg b/tests/loaders/data/jpeg/valid/100x100-cmyk-red.jpeg
new file mode 100644
index 00000000..cecf0700
Binary files /dev/null and b/tests/loaders/data/jpeg/valid/100x100-cmyk-red.jpeg differ
diff --git a/tests/loaders/data/jpeg/valid/100x100-grayscale-black.jpeg b/tests/loaders/data/jpeg/valid/100x100-grayscale-black.jpeg
new file mode 100644
index 00000000..f0fd04bf
Binary files /dev/null and b/tests/loaders/data/jpeg/valid/100x100-grayscale-black.jpeg differ
diff --git a/tests/loaders/data/jpeg/valid/100x100-grayscale-white.jpeg b/tests/loaders/data/jpeg/valid/100x100-grayscale-white.jpeg
new file mode 100644
index 00000000..37ac78ff
Binary files /dev/null and b/tests/loaders/data/jpeg/valid/100x100-grayscale-white.jpeg differ
diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt
index d36b2a3e..adf857ea 100644
--- a/tests/loaders/test_list.txt
+++ b/tests/loaders/test_list.txt
@@ -1,6 +1,7 @@
# Loaders testsuite
loaders_suite
PNG
+JPG
GIF
PBM
PGM
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_JPG.c | 2 +-
tests/loaders/.gitignore | 1 +
tests/loaders/{GIF.c => JPG.c} | 87 ++++++++++++++++++--
tests/loaders/Makefile | 5 +-
.../loaders/data/jpeg/valid/100x100-cmyk-red.jpeg | Bin 0 -> 454 bytes
.../data/jpeg/valid/100x100-grayscale-black.jpeg | Bin 0 -> 367 bytes
.../data/jpeg/valid/100x100-grayscale-white.jpeg | Bin 0 -> 367 bytes
tests/loaders/test_list.txt | 1 +
8 files changed, 86 insertions(+), 10 deletions(-)
copy tests/loaders/{GIF.c => JPG.c} (53%)
create mode 100644 tests/loaders/data/jpeg/valid/100x100-cmyk-red.jpeg
create mode 100644 tests/loaders/data/jpeg/valid/100x100-grayscale-black.jpeg
create mode 100644 tests/loaders/data/jpeg/valid/100x100-grayscale-white.jpeg
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
03 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 93832f616ef3ea2dde888cf8e0b7e1a2da077d06 (commit)
from ac5ab1fc384840bd63b923cd8d02043176676d01 (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/93832f616ef3ea2dde888cf8e0b7e1a2da07…
commit 93832f616ef3ea2dde888cf8e0b7e1a2da077d06
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 2 23:29:31 2014 +0200
loaders: BMP: Use IO for saving.
Adds GP_IOWriteF() and converts BMP saver to it.
There is also new GP_WriteBMP() function that takes
opened IO instead of a path as a parameter.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt
index f8c1d68c..b73506dd 100644
--- a/build/syms/Loaders_symbols.txt
+++ b/build/syms/Loaders_symbols.txt
@@ -15,6 +15,7 @@ GP_LoadPNGMetaData
GP_SavePNG
GP_MatchBMP
+GP_WriteBMP
GP_LoadBMP
GP_ReadBMP
GP_SaveBMP
@@ -109,6 +110,7 @@ GP_IOFill
GP_IOReadF
GP_IOReadB2
GP_IOReadB4
+GP_IOWriteF
GP_IOZlib
GP_IOZlibReset
diff --git a/include/loaders/GP_BMP.h b/include/loaders/GP_BMP.h
index 48eff73a..047d7733 100644
--- a/include/loaders/GP_BMP.h
+++ b/include/loaders/GP_BMP.h
@@ -41,6 +41,14 @@ GP_Context *GP_ReadBMP(GP_IO *io, GP_ProgressCallback *callback);
GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback);
/*
+ * Writes a BMP to an IO Stream.
+ *
+ * Returns zero on success, non-zero on failure and errno is set.
+ */
+int GP_WriteBMP(const GP_Context *src, GP_IO *io,
+ GP_ProgressCallback *callback);
+
+/*
* Saves BMP to a file. Zero is returned on succes. Upon failure non-zero is
* returned and errno is filled accordingly.
*/
diff --git a/include/loaders/GP_IO.h b/include/loaders/GP_IO.h
index 6947e3b3..19a1c78e 100644
--- a/include/loaders/GP_IO.h
+++ b/include/loaders/GP_IO.h
@@ -173,6 +173,8 @@ enum GP_IOReadFTypes {
int GP_IOReadF(GP_IO *self, uint16_t *types, ...);
+int GP_IOWriteF(GP_IO *self, uint16_t *types, ...);
+
/*
* GP_IOReadF wrappers for convinient reading of single value
*/
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index cc03a5e3..1d9e9c20 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -226,8 +226,7 @@ static int read_bitmap_info_header(GP_IO *io, struct bitmap_info_header *header)
/* This must be 1 according to specs */
if (nr_planes != 1)
- GP_DEBUG(1, "Number of planes is %"PRId16" should be 1",
- nr_planes);
+ GP_WARN("Number of planes %"PRId16" should be 1", nr_planes);
GP_DEBUG(2, "Have BMP bitmap size %"PRId32"x%"PRId32" %"PRIu16" "
"bpp, %"PRIu32" pallete colors, '%s' compression",
@@ -742,22 +741,43 @@ static uint32_t bmp_count_bitmap_size(struct bitmap_info_header *header)
return header->h * bmp_align_row_size(header->bpp * header->w);
}
-static int bmp_write_header(struct bitmap_info_header *header, FILE *f)
+static int bmp_write_header(GP_IO *io, struct bitmap_info_header *header)
{
uint32_t bitmap_size = bmp_count_bitmap_size(header);
uint32_t file_size = bitmap_size + header->header_size + 14;
- /* Bitmap Header */
- if (GP_FWrite(f, "A2 L4 0x00 0x00 0x00 0x00 L4", "BM",
- file_size, header->pixel_offset) != 7)
+ uint16_t bitmap_header[] = {
+ 'B', 'M', /* signature */
+ GP_IO_L4, /* pixels offset */
+ 0x00, 0x00, 0x00, 0x00, /* reserved */
+ GP_IO_L4, /* file size */
+ GP_IO_END,
+ };
+
+ if (GP_IOWriteF(io, bitmap_header, file_size, header->pixel_offset))
return EIO;
- /* Bitmap Info Header */
- if (GP_FWrite(f, "L4 L4 L4 L2 L2 L4 L4 L4 L4 L4 L4",
- header->header_size, header->w, header->h, 1,
- header->bpp, header->compress_type, bitmap_size, 0, 0,
- header->palette_colors, 0) != 11)
+ uint16_t bitmap_info_header[] = {
+ GP_IO_L4, /* header size */
+ GP_IO_L4, /* width */
+ GP_IO_L4, /* height */
+ 0x01, 0x00, /* nr planes, always 1 */
+ GP_IO_L2, /* bpp */
+ GP_IO_L4, /* compression type */
+ GP_IO_L4, /* bitmap size */
+ 0, 0, 0, 0, /* X PPM */
+ 0, 0, 0, 0, /* Y PPM */
+ GP_IO_L4, /* palette colors */
+ 0, 0, 0, 0, /* important palette colors */
+ GP_IO_END,
+ };
+
+ if (GP_IOWriteF(io, bitmap_info_header, header->header_size,
+ header->w, header->h, header->bpp,
+ header->compress_type, bitmap_size,
+ header->palette_colors)) {
return EIO;
+ }
return 0;
}
@@ -796,7 +816,8 @@ static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *hea
return 0;
}
-static int bmp_write_data(FILE *f, const GP_Context *src, GP_ProgressCallback *callback)
+static int bmp_write_data(GP_IO *io, const GP_Context *src,
+ GP_ProgressCallback *callback)
{
int y;
uint32_t padd_len = 0;
@@ -817,13 +838,14 @@ static int bmp_write_data(FILE *f, const GP_Context *src, GP_ProgressCallback *c
row = tmp;
}
- if (fwrite(row, src->bytes_per_row, 1, f) != 1)
+ if (GP_IOWrite(io, row, src->bytes_per_row) != src->bytes_per_row)
return EIO;
/* write padding */
- if (padd_len)
- if (fwrite(padd, padd_len, 1, f) != 1)
+ if (padd_len) {
+ if (GP_IOWrite(io, padd, padd_len) != padd_len)
return EIO;
+ }
if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
GP_DEBUG(1, "Operation aborted");
@@ -831,50 +853,55 @@ static int bmp_write_data(FILE *f, const GP_Context *src, GP_ProgressCallback *c
}
}
+ GP_ProgressCallbackDone(callback);
+
return 0;
}
-int GP_SaveBMP(const GP_Context *src, const char *dst_path,
- GP_ProgressCallback *callback)
+int GP_WriteBMP(const GP_Context *src, GP_IO *io,
+ GP_ProgressCallback *callback)
{
struct bitmap_info_header header;
- FILE *f;
int err;
- GP_DEBUG(1, "Saving BMP Image '%s'", dst_path);
-
if ((err = bmp_fill_header(src, &header)))
- goto err0;
+ goto err;
- f = fopen(dst_path, "wb");
+ if ((err = bmp_write_header(io, &header)))
+ goto err;
- if (f == NULL) {
- err = errno;
- GP_DEBUG(1, "Failed to open '%s' for writing: %s",
- dst_path, strerror(errno));
- goto err0;
- }
+ if ((err = bmp_write_data(io, src, callback)))
+ goto err;
- if ((err = bmp_write_header(&header, f)))
- goto err1;
+ return 0;
+err:
+ errno = err;
+ return 1;
+}
- if ((err = bmp_write_data(f, src, callback)))
- goto err1;
- if (fclose(f)) {
- err = errno;
- GP_DEBUG(1, "Failed to close file '%s': %s",
- dst_path, strerror(errno));
- goto err1;
+int GP_SaveBMP(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback)
+{
+ GP_IO *io;
+
+ GP_DEBUG(1, "Saving BMP Image '%s'", dst_path);
+
+ io = GP_IOFile(dst_path, GP_IO_WRONLY);
+
+ if (!io)
+ return 1;
+
+ if (GP_WriteBMP(src, io, callback)) {
+ GP_IOClose(io);
+ unlink(dst_path);
+ return 1;
}
- GP_ProgressCallbackDone(callback);
+ if (GP_IOClose(io)) {
+ unlink(dst_path);
+ return 1;
+ }
return 0;
-err1:
- fclose(f);
-err0:
- unlink(dst_path);
- errno = err;
- return 1;
}
diff --git a/libs/loaders/GP_IO.c b/libs/loaders/GP_IO.c
index 0b77bd5c..145058b8 100644
--- a/libs/loaders/GP_IO.c
+++ b/libs/loaders/GP_IO.c
@@ -27,6 +27,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
+#include <inttypes.h>
#include <core/GP_ByteOrder.h>
#include <core/GP_Debug.h>
@@ -612,6 +613,60 @@ end:
return ret;
}
+int GP_IOWriteF(GP_IO *io, uint16_t *types, ...)
+{
+ va_list va;
+ uint8_t *ptr, t;
+ int32_t i4;
+ int16_t i2;
+
+ va_start(va, types);
+
+ while (*types != GP_IO_END) {
+ switch (TYPE(*types)) {
+ case GP_IO_CONST:
+ t = VAL(*types);
+ if (GP_IOWrite(io, &t, 1) != 1)
+ goto err;
+ break;
+ case GP_IO_L2:
+ case GP_IO_B2:
+ i2 = va_arg(va, int);
+ ptr = (void*)&i2;
+
+ if (needs_swap(*types))
+ GP_SWAP(ptr[0], ptr[1]);
+
+ if (GP_IOWrite(io, ptr, 2) != 2)
+ goto err;
+ break;
+ case GP_IO_L4:
+ case GP_IO_B4:
+ i4 = va_arg(va, int);
+ ptr = (void*)&i4;
+
+ if (needs_swap(*types)) {
+ GP_SWAP(ptr[0], ptr[3]);
+ GP_SWAP(ptr[1], ptr[2]);
+ }
+
+ if (GP_IOWrite(io, ptr, 4) != 4)
+ goto err;
+ break;
+ default:
+ GP_WARN("Invalid type %"PRIu16"n", *types);
+ goto err;
+ }
+ types++;
+ }
+
+ va_end(va);
+ return 0;
+err:
+ va_end(va);
+ return -1;
+}
+
int GP_IOReadB4(GP_IO *io, uint32_t *val)
{
uint16_t desc[] = {
-----------------------------------------------------------------------
Summary of changes:
build/syms/Loaders_symbols.txt | 2 +
include/loaders/GP_BMP.h | 8 +++
include/loaders/GP_IO.h | 2 +
libs/loaders/GP_BMP.c | 115 ++++++++++++++++++++++++---------------
libs/loaders/GP_IO.c | 55 +++++++++++++++++++
5 files changed, 138 insertions(+), 44 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 Apr '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 ac5ab1fc384840bd63b923cd8d02043176676d01 (commit)
from 34edb5f159d98fccc62cfdcd268f51109320dafd (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/ac5ab1fc384840bd63b923cd8d0204317667…
commit ac5ab1fc384840bd63b923cd8d02043176676d01
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 25 23:37:17 2014 +0200
spiv: Fix slow blit for images with alpha channel
The pattern_fill() function that draws chessboard like pattern before
images with alpha channel are blitted was drawing the pattern pixel by
pixel, which is quite slow and caused dropped events when moving such
image in the spiv window.
This commit optimizes the function a bit (about then times faster) which
fixes the problem.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 6d26c600..d4785e0a 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -171,26 +171,21 @@ static GP_Context *load_image(int elevate)
static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0,
unsigned int w, unsigned int h)
{
- unsigned int x, y;
+ unsigned int x, y, i, j = 0;
+ GP_Pixel col[2];
- GP_Pixel g1 = GP_RGBToContextPixel(0x64, 0x64, 0x64, ctx);
- GP_Pixel g2 = GP_RGBToContextPixel(0x80, 0x80, 0x80, ctx);
+ col[0] = GP_RGBToContextPixel(0x64, 0x64, 0x64, ctx);
+ col[1] = GP_RGBToContextPixel(0x80, 0x80, 0x80, ctx);
- unsigned int wm = w/10 < 10 ? 10 : w/10;
- unsigned int hm = h/10 < 10 ? 10 : h/10;
- unsigned int wt = w/20 < 5 ? 5 : w/20;
- unsigned int ht = h/20 < 5 ? 5 : h/20;
+ unsigned int wm = w/20 < 5 ? 5 : w/20;
+ unsigned int hm = h/20 < 5 ? 5 : h/20;
- for (y = 0; y < h; y++) {
- for (x = 0; x < w; x++) {
- GP_Pixel pix;
-
- if ((x % wm < wt) ^ (y % hm < ht))
- pix = g1;
- else
- pix = g2;
-
- GP_PutPixel(ctx, x0 + x, y0 + y, pix);
+ for (y = 0; y < h; y += hm) {
+ i = j;
+ j = !j;
+ for (x = 0; x < w; x += wm) {
+ GP_FillRectXYWH(ctx, x0 + x, y0 + y, wm, hm, col[i]);
+ i = !i;
}
}
}
@@ -323,7 +318,6 @@ static void update_display(struct loader_params *params, GP_Context *img,
} else {
if (GP_PixelHasFlags(img->pixel_type, GP_PIXEL_HAS_ALPHA))
pattern_fill(context, cx, cy, img->w, img->h);
-
GP_Blit_Clipped(img, 0, 0, img->w, img->h, context, cx, cy);
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 30 ++++++++++++------------------
1 files changed, 12 insertions(+), 18 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 Apr '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 34edb5f159d98fccc62cfdcd268f51109320dafd (commit)
from e667b1019551a0036d4ff8e7852bc51e2336440c (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/34edb5f159d98fccc62cfdcd268f51109320…
commit 34edb5f159d98fccc62cfdcd268f51109320dafd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 25 22:39:02 2014 +0200
loaders: PNG: Enable 8bit grayscale with alpha.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 770bb123..0ea37379 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -145,6 +145,13 @@ GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback)
#endif
}
break;
+ case PNG_COLOR_TYPE_GRAY | PNG_COLOR_MASK_ALPHA:
+ switch (depth) {
+ case 8:
+ pixel_type = GP_PIXEL_GA88;
+ break;
+ }
+ break;
case PNG_COLOR_TYPE_RGB:
png_set_bgr(png);
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_PNG.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
06 Apr '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 e667b1019551a0036d4ff8e7852bc51e2336440c (commit)
via 5cd65fd591736dece2f3765bd0ad8c2293a962fb (commit)
via 503997cdf771f276e66b81248040ea7c871453d1 (commit)
via b57c2a045e194efe832221f8b39f3321e138ef2e (commit)
via ef9820803deba6c74d0add5b20e6b05337d5b5ff (commit)
via d05cd390e18afe7121de02baf14db33c594718e0 (commit)
via c7229164ab9fd1a0b2cd56a5160c645cee47fc8f (commit)
via cca2aa0a2f23dc952ec63d022320053c4d532b04 (commit)
via 5e47080df0990f3c9deb18ecb83a98ae6dce0671 (commit)
via 9495fa1e62cd01f4dbbab631abcdc5ff0114c49d (commit)
from c4cb658954c2cd3de44939d096b48eb40438d674 (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/e667b1019551a0036d4ff8e7852bc51e2336…
commit e667b1019551a0036d4ff8e7852bc51e2336440c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 30 16:57:45 2014 +0200
pywrap: core: Add GP_Fill
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index 59b17e8a..ff0c0629 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -124,9 +124,8 @@ ERROR_ON_NULL(GP_SubContextAlloc);
/*
* Context manipulation
*/
-
%include "GP_GetPutPixel.h"
%import "GP_GetPutPixel.gen.h"
%include "GP_WritePixel.h"
%include "GP_Blit.h"
-
+%include "GP_Fill.h"
http://repo.or.cz/w/gfxprim.git/commit/5cd65fd591736dece2f3765bd0ad8c2293a9…
commit 5cd65fd591736dece2f3765bd0ad8c2293a962fb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 30 16:57:00 2014 +0200
core: Include GP_Fill.h in GP_Core.h.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h
index 38ee3c33..b9f1b6ac 100644
--- a/include/core/GP_Core.h
+++ b/include/core/GP_Core.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -77,4 +77,6 @@
/* Mix Pixel */
#include "core/GP_MixPixels.h"
+#include "core/GP_Fill.h"
+
#endif /* GP_CORE_H */
http://repo.or.cz/w/gfxprim.git/commit/503997cdf771f276e66b81248040ea7c8714…
commit 503997cdf771f276e66b81248040ea7c871453d1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 30 16:48:13 2014 +0200
Fix typos.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.1 b/demos/spiv/spiv.1
index bca63dd6..30bd5d9f 100644
--- a/demos/spiv/spiv.1
+++ b/demos/spiv/spiv.1
@@ -24,7 +24,7 @@ Spiv implements feh-like image actions, which are short shell scripts with
printf-like modifiers.
See
.B ACTIONS
-bellow for further information.
+below for further information.
.SH KEYBOARD CONTROL
.IP "Esc, Enter, Q"
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index cecd1ecb..9d018872 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -175,7 +175,7 @@ const char *man_head =
".PPn"
"Spiv implements feh-like image actions, which are short shell scripts withn"
"printf-like modifiers.n"
- "Seen.B ACTIONSnbellow for further information.n";
+ "Seen.B ACTIONSnbelow for further information.n";
static const char *man_tail =
".SH BUGSn"
diff --git a/include/core/GP_Debug.h b/include/core/GP_Debug.h
index 4008bcd6..0c6af6fd 100644
--- a/include/core/GP_Debug.h
+++ b/include/core/GP_Debug.h
@@ -37,7 +37,7 @@
There are few special debug message types with negative debug level (that
means that they are always printed), and as so these are used on various error
- conditions, see bellow for more information.
+ conditions, see below for more information.
*/
diff --git a/include/input/GP_EventQueue.h b/include/input/GP_EventQueue.h
index df251594..089fbfac 100644
--- a/include/input/GP_EventQueue.h
+++ b/include/input/GP_EventQueue.h
@@ -115,7 +115,7 @@ int GP_EventQueuePeek(struct GP_EventQueue *self, struct GP_Event *ev);
* Puts the event in the queue.
*
* This is bare call that just copies the event into the queue. Use the calls
- * bellow instead.
+ * below instead.
*/
void GP_EventQueuePut(struct GP_EventQueue *self, struct GP_Event *ev);
diff --git a/include/loaders/GP_Container.h b/include/loaders/GP_Container.h
index d3e9d0f5..2670bc58 100644
--- a/include/loaders/GP_Container.h
+++ b/include/loaders/GP_Container.h
@@ -44,7 +44,7 @@ enum GP_ContainerWhence {
struct GP_ContainerOps {
/*
* Loads next image from container, use the inline function defined
- * bellow.
+ * below.
*/
GP_Context *(*LoadNext)(struct GP_Container *self,
GP_ProgressCallback *callback);
@@ -56,7 +56,7 @@ struct GP_ContainerOps {
GP_ProgressCallback *callback);
/*
- * Close callback, use the inline function defined bellow.
+ * Close callback, use the inline function defined below.
*/
void (*Close)(struct GP_Container *self);
diff --git a/libs/loaders/GP_IOZlib.c b/libs/loaders/GP_IOZlib.c
index d0a7e00c..21b7fc72 100644
--- a/libs/loaders/GP_IOZlib.c
+++ b/libs/loaders/GP_IOZlib.c
@@ -137,7 +137,6 @@ static int zlib_reset(struct priv *priv)
priv->strm.avail_out = 0;
priv->strm.next_out = Z_NULL;
-
priv->bytes_read = 0;
priv->comp_avail = priv->comp_size;
priv->crc = crc32(0, NULL, 0);
@@ -151,7 +150,7 @@ static off_t zlib_seek(GP_IO *io, off_t offset, enum GP_IOWhence whence)
struct priv *priv = GP_IO_PRIV(io);
off_t ret;
- GP_DEBUG(3, "Seek %li %un", (long)offset, whence);
+ GP_DEBUG(3, "Seek %li %u", (long)offset, whence);
if (whence == GP_IO_SEEK_CUR) {
if (offset == 0)
http://repo.or.cz/w/gfxprim.git/commit/b57c2a045e194efe832221f8b39f3321e138…
commit b57c2a045e194efe832221f8b39f3321e138ef2e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 30 16:47:36 2014 +0200
doc: Add filter images, fix typos.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/backends.txt b/doc/backends.txt
index 9b0c392c..944c13f3 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -176,7 +176,7 @@ void GP_BackendX11RequestFullscreen(GP_Backend *self, int mode);
The 'GP_BackendX11RequestFullscreen' can toggle fullscreen mode at runtime.
-It will most likely generate resize event. See the 'GP_BackendResizeAck()' bellow.
+It will most likely generate resize event. See the 'GP_BackendResizeAck()' below.
AA-lib
~~~~~~
@@ -344,7 +344,7 @@ when data are ready on file-descriptor.
If the backend is the only source of events in your application, you should
consider using the 'GP_BackendWait()' or 'GP_BackendEventWait()' described
-bellow.
+below.
GP_BackendPollEvent
^^^^^^^^^^^^^^^^^^^
@@ -593,7 +593,7 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h);
Requests backend resize. If backend resize is supported and the resize request
was successful (i.e. X server allowed us to resize the window) the resize
event will be send and should be handled in your event loop. You must respond
-to it by the 'GP_BackendResizeAck()' described bellow.
+to it by the 'GP_BackendResizeAck()' described below.
NOTE: The backend->context pointer may change upon calling this function and
at least backend->context->pixels pointer will change.
diff --git a/doc/blits.txt b/doc/blits.txt
index e2982e6e..d2e4e372 100644
--- a/doc/blits.txt
+++ b/doc/blits.txt
@@ -45,7 +45,7 @@ WARNING: For these functions the behavior is undefined when you pass
coordinates or width or height outside of the source or destination
pixmap. If you need safe variant that automatically clips the
coordinates and rectangle to fit both the source and destination use
- the Clipped variants described bellow.
+ the Clipped variants described below.
[source,c]
diff --git a/doc/context.txt b/doc/context.txt
index c59c714e..37287f7e 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -58,7 +58,7 @@ gamma correction. Unfortunatelly very few parts of the library use it at the
moment (this will be fixed in subsequent releases).
The bitfield at the the end of the structure describes image orientation (see
-bellow) and a flag that tell if 'pixels' data should be freed, which is
+below) and a flag that tell if 'pixels' data should be freed, which is
usefull for example for <<Sub_Context, subcontexts>>.
Rotation
diff --git a/doc/debug.txt b/doc/debug.txt
index e5f0015e..09c80aa0 100644
--- a/doc/debug.txt
+++ b/doc/debug.txt
@@ -17,7 +17,7 @@ debug level lower or equal to debug level are printed.
There are few special debug message types with negative debug level (that
means that they are always printed), and as so these are used on various error
-conditions, see bellow for more information.
+conditions, see below for more information.
[source,c]
-------------------------------------------------------------------------------
diff --git a/doc/environment_variables.txt b/doc/environment_variables.txt
index 85b6758d..5ce7488a 100644
--- a/doc/environment_variables.txt
+++ b/doc/environment_variables.txt
@@ -10,7 +10,7 @@ GP_THREADS
'GP_THREADS' overrides GP_NrThreadsSet() settings. The value is the same as it
would have been set by GP_NrThreadsSet() which is described in the table
-bellow:
+below:
.GP_THREADS possible values
[width="60%",options="header"]
diff --git a/doc/filters.txt b/doc/filters.txt
index 1ed37f09..c0cc5466 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -322,6 +322,8 @@ Works 'in-place'.
The destination has to have the same pixel type and the size must be at least
as large as source.
+include::images/mirror_h/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
@@ -342,6 +344,8 @@ Works 'in-place'.
The destination has to have the same pixel type and the size must be at least
as large as source.
+include::images/mirror_v/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
@@ -362,6 +366,8 @@ Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and size must be large enough to
fit rotated context (i.e. W and H are swapped).
+include::images/rotate_90/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
@@ -382,6 +388,8 @@ Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and the size must be at least
as large as source.
+include::images/rotate_180/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
@@ -402,6 +410,8 @@ Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and destination size must be
large enough to fit rotated context (i.e. W and H are swapped).
+include::images/rotate_270/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
http://repo.or.cz/w/gfxprim.git/commit/ef9820803deba6c74d0add5b20e6b05337d5…
commit ef9820803deba6c74d0add5b20e6b05337d5b5ff
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:46:17 2014 +0100
loaders: zip: Make use of Zlib stream.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index 7928023d..440aabbf 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -34,12 +34,12 @@
#endif /* HAVE_ZLIB */
-#include "core/GP_Common.h"
-#include "core/GP_Debug.h"
-
-#include "loaders/GP_ByteUtils.h"
-#include "loaders/GP_Loader.h"
+#include <core/GP_Common.h>
+#include <core/GP_Debug.h>
+#include <loaders/GP_ByteUtils.h>
+#include <loaders/GP_Loader.h>
+#include <loaders/GP_IOZlib.h>
#include "loaders/GP_ZIP.h"
#ifdef HAVE_ZLIB
@@ -132,7 +132,7 @@ enum zip_flags {
/* File is encrypted */
FLAG_ENCRYPTED = 0x0001,
/* Size and CRC are in data descriptor after the compressed data */
- FLAG_ZERO_SIZE_CRC = 0x0008,
+ FLAG_DATA_DESC_HEADER = 0x0008,
/* Filename and comment fileds are in UTF-8 */
FLAG_UTF8 = 0x0800,
};
@@ -142,7 +142,7 @@ static void print_flags(struct zip_local_header *header)
if (header->flags & FLAG_ENCRYPTED)
GP_DEBUG(2, "File is encrypted");
- if (header->flags & FLAG_ZERO_SIZE_CRC)
+ if (header->flags & FLAG_DATA_DESC_HEADER)
GP_DEBUG(2, "File size and CRC are after compressed data");
if (header->flags & FLAG_UTF8)
@@ -165,162 +165,6 @@ static int seek_bytes(GP_IO *io, uint32_t bytes)
return 0;
}
-#define CHUNK 512
-
-struct deflate_inbuf {
- struct zip_local_header *zip_header;
- uint32_t to_read;
- unsigned char buf[CHUNK];
- GP_IO *io;
-};
-
-struct deflate_outbuf {
- uint32_t crc;
- uint32_t size;
- uint32_t fill;
- uint8_t *buf;
-};
-
-static unsigned deflate_in(void *in_desc, unsigned char **buf)
-{
- struct deflate_inbuf *in = in_desc;
- int chunk, ret;
-
- if (in->to_read)
- chunk = in->to_read >= CHUNK ? CHUNK : in->to_read;
- else
- chunk = CHUNK;
-
- ret = GP_IORead(in->io, in->buf, chunk);
-
- if (ret <= 0)
- return ret;
-
- *buf = in->buf;
-
- if (in->to_read)
- in->to_read -= ret;
-
- return ret;
-}
-
-#define BUFINC (1024 * 128)
-
-static int deflate_out(void *out_desc, unsigned char *buf, unsigned len)
-{
- struct deflate_outbuf *out = out_desc;
-
- if (out->fill + len >= out->size) {
- out->buf = realloc(out->buf, out->size + GP_MAX(len, BUFINC));
- if (!out->buf)
- return 1;
- out->size += GP_MAX(len, BUFINC);
- GP_DEBUG(1, "Realloc %u %p", out->size, out->buf);
- }
-
- out->crc = crc32(out->crc, buf, len);
- memcpy(out->buf + out->fill, buf, len);
- out->fill += len;
-
- return 0;
-}
-
-static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio)
-{
- uint8_t *window;
- int err = 0, ret;
- uint8_t *buf;
- unsigned int bufsize = header->uncomp_size ? header->uncomp_size : BUFINC;
-
- window = malloc(32 * 1024);
-
- //TODO: Unsafe
- buf = malloc(bufsize);
-
- if (!window || !buf) {
- err = ENOMEM;
- goto err1;
- }
-
- z_stream strm = {
- .zalloc = Z_NULL,
- .zfree = Z_NULL,
- .opaque = Z_NULL,
- .next_in = Z_NULL,
- };
-
- if (inflateBackInit(&strm, 15, window) != Z_OK) {
- GP_DEBUG(1, "Failed to initialize inflate stream");
- //TODO: Better errno?
- err = EIO;
- goto err1;
- }
-
- struct deflate_outbuf outbuf = {
- .crc = crc32(0, NULL, 0),
- .size = bufsize,
- .fill = 0,
- .buf = buf,
- };
-
- struct deflate_inbuf inbuf = {
- .zip_header = header,
- .io = io,
- .to_read = header->comp_size,
- };
-
- ret = inflateBack(&strm, deflate_in, &inbuf, deflate_out, &outbuf);
-
- if (ret != Z_STREAM_END) {
- GP_DEBUG(1, "Failed to inflate stream %i", ret);
- err = EINVAL;
- goto err2;
- }
-
- if (header->flags & FLAG_ZERO_SIZE_CRC) {
- GP_DEBUG(2, "In buffer %i, seeking back", strm.avail_in);
- GP_IOSeek(io, -(int)strm.avail_in, GP_IO_SEEK_CUR);
- uint16_t data_desc_header[] = {
- 'P', 'K', 0x07, 0x08, /* Data desc header */
- GP_IO_L4, /* CRC */
- GP_IO_L4, /* Compressed size */
- GP_IO_L4, /* Uncompressed size */
- GP_IO_END
- };
-
- if (GP_IOReadF(io, data_desc_header, &header->crc,
- &header->comp_size, &header->uncomp_size) != 7) {
- GP_DEBUG(1, "Failed to read Data Description Header");
- goto err2;
- }
- }
-
- if (outbuf.crc != header->crc) {
- GP_DEBUG(1, "CRC does not match");
- err = EIO;
- goto err2;
- }
-
- if (outbuf.fill != header->uncomp_size) {
- GP_DEBUG(1, "Decompressed size does not match");
- err = EIO;
- goto err2;
- }
-
- inflateBackEnd(&strm);
- free(window);
-
- //TODO: Failure
- *rio = GP_IOMem(outbuf.buf, outbuf.size, free);
- return 0;
-err2:
- inflateBackEnd(&strm);
-err1:
- free(window);
- free(outbuf.buf);
- return err;
-}
-
static int zip_load_header(GP_IO *io, struct zip_local_header *header)
{
int ret;
@@ -379,6 +223,25 @@ static int zip_load_header(GP_IO *io, struct zip_local_header *header)
return 0;
}
+static int zip_read_data_desc(GP_IO *io, struct zip_local_header *header)
+{
+ uint16_t data_desc_header[] = {
+ 'P', 'K', 0x07, 0x08, /* Data desc header */
+ GP_IO_L4, /* CRC */
+ GP_IO_L4, /* Compressed size */
+ GP_IO_L4, /* Uncompressed size */
+ GP_IO_END
+ };
+
+ if (GP_IOReadF(io, data_desc_header, &header->crc,
+ &header->comp_size, &header->uncomp_size) != 7) {
+ GP_DEBUG(1, "Failed to read Data Description Header");
+ return 1;
+ }
+
+ return 0;
+}
+
static GP_Context *zip_next_file(struct zip_priv *priv,
GP_ProgressCallback *callback)
{
@@ -415,7 +278,7 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
}
header.file_name[header.fname_len] = '0';
-
+ //FILL
if (GP_IORead(priv->io, header.file_name, header.fname_len) != header.fname_len) {
GP_DEBUG(1, "Failed to read filename");
err = EIO;
@@ -449,7 +312,7 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
goto out;
break;
case COMPRESS_DEFLATE:
- if ((err = read_deflate(priv->io, &header, &io))) {
+ /* if ((err = read_deflate(priv->io, &header, &io))) {
err = errno;
goto out;
}
@@ -460,6 +323,24 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
GP_IOClose(io);
goto out;
+ */
+ io = GP_IOZlib(priv->io, header.comp_size);
+ if (!io)
+ goto out;
+
+ GP_DEBUG(1, "Reading image");
+ ret = GP_ReadImage(io, callback);
+ if (errno == ECANCELED)
+ err = errno;
+
+ GP_IOClose(io);
+
+ if (header.flags & FLAG_DATA_DESC_HEADER) {
+ if (zip_read_data_desc(priv->io, &header))
+ goto out;
+ }
+
+ goto out;
break;
default:
GP_DEBUG(1, "Unimplemented compression %s",
@@ -551,6 +432,8 @@ static GP_Context *zip_load_next(GP_Container *self,
if (ret)
record_offset(priv, offset);
+ record_offset(priv, GP_IOTell(priv->io));
+
priv->cur_pos++;
//self->cur_img++;
self->cur_img = priv->cur_pos;
http://repo.or.cz/w/gfxprim.git/commit/d05cd390e18afe7121de02baf14db33c5947…
commit d05cd390e18afe7121de02baf14db33c594718e0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:45:22 2014 +0100
libs: loaders: Create Zlib decompression stream
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt
index dfbb1e54..f8c1d68c 100644
--- a/build/syms/Loaders_symbols.txt
+++ b/build/syms/Loaders_symbols.txt
@@ -109,3 +109,6 @@ GP_IOFill
GP_IOReadF
GP_IOReadB2
GP_IOReadB4
+
+GP_IOZlib
+GP_IOZlibReset
diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_IOZlib.h
similarity index 65%
copy from include/loaders/GP_Loaders.h
copy to include/loaders/GP_IOZlib.h
index a80eb6e2..70486dfb 100644
--- a/include/loaders/GP_Loaders.h
+++ b/include/loaders/GP_IOZlib.h
@@ -16,43 +16,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
* Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
- Core include file for loaders API.
+ Zlib decompression stream.
*/
-#ifndef LOADERS_GP_LOADERS_H
-#define LOADERS_GP_LOADERS_H
-
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-
-#include "loaders/GP_PNM.h"
-#include "loaders/GP_BMP.h"
-#include "loaders/GP_PNG.h"
-#include "loaders/GP_JPG.h"
-#include "loaders/GP_JP2.h"
-#include "loaders/GP_GIF.h"
-#include "loaders/GP_TIFF.h"
-#include "loaders/GP_PCX.h"
-#include "loaders/GP_PSP.h"
-#include "loaders/GP_PSD.h"
-
-#include "loaders/GP_TmpFile.h"
-
-#include "loaders/GP_MetaData.h"
-
-#include "loaders/GP_Loader.h"
-
-#include "loaders/GP_Container.h"
-#include "loaders/GP_ZIP.h"
-
-#endif /* LOADERS_GP_LOADERS_H */
+#ifndef LOADERS_GP_IO_ZLIB_H
+#define LOADERS_GP_IO_ZLIB_H
+
+#include <loaders/GP_IO.h>
+
+/*
+ * Create an Zlib RAW inflate stream on the top of the existing I/O stream.
+ *
+ * The stream will read up to comp_size bytes from the parent I/O.
+ *
+ * If comp_size is 0, no limit on number bytes from the parent stream is set.
+ * However if end of compressed stream is reached the last read will attempt to
+ * seek back by the number of extra buffered bytes.
+ */
+GP_IO *GP_IOZlib(GP_IO *io, size_t comp_size);
+
+/*
+ * Repurposes existing Zlib stream for new decompression.
+ *
+ * Returns zero on success. Returns non-zero on failure and errno is set.
+ */
+int GP_IOZlibReset(GP_IO *io, GP_IO *sub_io, size_t comp_size);
+
+#endif /* LOADERS_GP_IO_ZLIB_H */
diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_Loaders.h
index a80eb6e2..e93412c6 100644
--- a/include/loaders/GP_Loaders.h
+++ b/include/loaders/GP_Loaders.h
@@ -55,4 +55,6 @@
#include "loaders/GP_Container.h"
#include "loaders/GP_ZIP.h"
+#include "loaders/GP_IOZlib.h"
+
#endif /* LOADERS_GP_LOADERS_H */
diff --git a/libs/loaders/GP_IOZlib.c b/libs/loaders/GP_IOZlib.c
new file mode 100644
index 00000000..d0a7e00c
--- /dev/null
+++ b/libs/loaders/GP_IOZlib.c
@@ -0,0 +1,259 @@
+/*****************************************************************************
+ * 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 "../../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>
+
+#define BUFS 512u
+
+struct priv {
+ z_stream strm;
+
+ GP_IO *io;
+ off_t io_start;
+ int eos;
+
+ uint32_t crc;
+ size_t comp_avail;
+ size_t comp_size;
+ size_t bytes_read;
+
+ char inbuf[BUFS];
+};
+
+static int zlib_close(GP_IO *io)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+
+ GP_DEBUG(1, "Closing IO (%p)", io);
+
+ inflateEnd(&priv->strm);
+ free(io);
+
+ return 0;
+}
+
+static ssize_t zlib_read(GP_IO *io, void *buf, size_t size)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+ size_t bread;
+ int ret;
+
+ GP_DEBUG(3, "Read %p %zu", buf, size);
+
+ if (priv->eos)
+ return 0;
+
+ priv->strm.avail_out = size;
+ priv->strm.next_out = buf;
+
+ do {
+ if (priv->strm.avail_in == 0) {
+ size_t to_read = BUFS;
+
+ if (priv->comp_avail)
+ to_read = GP_MIN(BUFS, priv->comp_avail);
+
+ ret = GP_IORead(priv->io, priv->inbuf, to_read);
+
+ if (ret <= 0)
+ return ret;
+
+ if (priv->comp_avail)
+ priv->comp_avail -= ret;
+
+ priv->strm.avail_in = ret;
+ priv->strm.next_in = (void*)priv->inbuf;
+ }
+
+ //priv->strm.next_out = buf + (size - priv->strm.avail_out);
+ ret = inflate(&priv->strm, Z_NO_FLUSH);
+
+ switch (ret) {
+ case Z_OK:
+ break;
+ case Z_STREAM_END:
+ GP_DEBUG(1, "End of stream");
+
+ priv->eos = 1;
+
+ /* Attempt to seek back in the parent I/O stream */
+ if (priv->strm.avail_in) {
+ GP_DEBUG(1, "Seeking back by %zu", (size_t)priv->strm.avail_in);
+ GP_IOSeek(priv->io, -(int)priv->strm.avail_in, GP_IO_SEEK_CUR);
+ }
+
+ goto out;
+ break;
+ default:
+ GP_DEBUG(1, "inflate() failed %i", ret);
+ errno = EIO;
+ return -1;
+ }
+ } while (priv->strm.avail_out == size);
+
+out:
+ bread = size - priv->strm.avail_out;
+ priv->bytes_read += bread;
+ priv->crc = crc32(priv->crc, buf, bread);
+
+ return bread;
+}
+
+static int zlib_reset(struct priv *priv)
+{
+ inflateReset(&priv->strm);
+
+ priv->strm.avail_in = 0;
+ priv->strm.next_in = Z_NULL;
+
+ priv->strm.avail_out = 0;
+ priv->strm.next_out = Z_NULL;
+
+
+ priv->bytes_read = 0;
+ priv->comp_avail = priv->comp_size;
+ priv->crc = crc32(0, NULL, 0);
+ priv->eos = 0;
+
+ return 0;
+}
+
+static off_t zlib_seek(GP_IO *io, off_t offset, enum GP_IOWhence whence)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+ off_t ret;
+
+ GP_DEBUG(3, "Seek %li %un", (long)offset, whence);
+
+ if (whence == GP_IO_SEEK_CUR) {
+ if (offset == 0)
+ return priv->bytes_read;
+ if (offset < 0)
+ goto out;
+ char b[offset];
+ priv->bytes_read += offset;
+ GP_IOFill(io, b, offset);
+ return priv->bytes_read;
+ }
+
+ if (whence == GP_IO_SEEK_SET && offset == 0) {
+ ret = GP_IOSeek(priv->io, priv->io_start, GP_IO_SEEK_SET);
+
+ if (ret == (off_t)-1)
+ return ret;
+
+ if (zlib_reset(priv))
+ return (off_t)-1;
+
+ return 0;
+ }
+out:
+ errno = ENOSYS;
+ return (off_t)-1;
+}
+
+int GP_IOZlibReset(GP_IO *io, GP_IO *sub_io, size_t comp_size)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+
+ GP_DEBUG(1, "Resseting I/O (%p) (parent %p) size %zu",
+ io, sub_io, comp_size);
+
+ priv->io = sub_io;
+ priv->comp_size = comp_size;
+
+ return zlib_reset(priv);
+}
+
+GP_IO *GP_IOZlib(GP_IO *io, size_t comp_size)
+{
+ GP_IO *new = malloc(sizeof(GP_IO) + sizeof(struct priv));
+ struct priv *priv;
+ int err, ret;
+
+ if (!new) {
+ GP_DEBUG(1, "Malloc failed :(");
+ return NULL;
+ }
+
+ priv = GP_IO_PRIV(new);
+
+ priv->io = io;
+ priv->comp_avail = comp_size;
+ priv->comp_size = comp_size;
+ priv->bytes_read = 0;
+ priv->crc = crc32(0, NULL, 0);
+ priv->io_start = GP_IOTell(io);
+ priv->eos = 0;
+
+ priv->strm.zalloc = Z_NULL;
+ priv->strm.zfree = Z_NULL;
+ priv->strm.opaque = Z_NULL;
+ priv->strm.avail_in = Z_NULL;
+ priv->strm.next_in = Z_NULL;
+
+ ret = inflateInit2(&priv->strm, -15);
+ if (ret != Z_OK) {
+ //TODO better err and message
+ GP_DEBUG(1, "inflateInit() failed: %i", ret);
+ err = EIO;
+ goto err1;
+ }
+
+ //INIT IO
+ new->Close = zlib_close;
+ new->Read = zlib_read;
+ new->Write = NULL;
+ new->Seek = zlib_seek;
+
+ GP_DEBUG(1, "Initialized ZlibIO (%p)", new);
+
+ return new;
+err1:
+ free(new);
+ errno = err;
+ return NULL;
+}
+
+#else
+
+GP_IO *GP_IOZlib(GP_IO *io, size_t comp_size)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+
+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/c7229164ab9fd1a0b2cd56a5160c645cee47…
commit c7229164ab9fd1a0b2cd56a5160c645cee47fc8f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:44:55 2014 +0100
spiv: Show pixel type in info.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index ca374085..6d26c600 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -231,9 +231,9 @@ static void show_info(struct loader_params *params, GP_Context *img,
GP_Size th = GP_TextHeight(NULL), y = 10;
- info_printf(context, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%%",
+ info_printf(context, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%% %s",
img->w, img->h, orig_img->w, orig_img->h, params->zoom_rat,
- params->zoom_rat * 100);
+ params->zoom_rat * 100, GP_PixelTypeName(img->pixel_type));
y += th + 2;
info_printf(context, 10, y, "%s", img_name(img_path));
http://repo.or.cz/w/gfxprim.git/commit/cca2aa0a2f23dc952ec63d022320053c4d53…
commit cca2aa0a2f23dc952ec63d022320053c4d532b04
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:25:24 2014 +0100
loaders: PNG: Use GP_IOFill() to fill whole buffer
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 71812ba2..770bb123 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -63,12 +63,9 @@ static const char *interlace_type_name(int interlace)
static void read_data(png_structp png_ptr, png_bytep data, png_size_t len)
{
- int res;
GP_IO *io = png_get_io_ptr(png_ptr);
- res = GP_IORead(io, data, len);
-
- if (res < 0 || (png_size_t)res != len)
+ if (GP_IOFill(io, data, len))
png_error(png_ptr, "Read Error");
}
http://repo.or.cz/w/gfxprim.git/commit/5e47080df0990f3c9deb18ecb83a98ae6dce…
commit 5e47080df0990f3c9deb18ecb83a98ae6dce0671
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:17:21 2014 +0100
spiv: Fix -t for zip container.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/image_loader.c b/demos/spiv/image_loader.c
index e03426e0..d0335294 100644
--- a/demos/spiv/image_loader.c
+++ b/demos/spiv/image_loader.c
@@ -67,7 +67,9 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate)
return cur_img;
if (cur_cont) {
+ cpu_timer_start(&timer, "Loading");
cur_img = GP_ContainerLoad(cur_cont, callback);
+ cpu_timer_stop(&timer);
return cur_img;
}
@@ -97,6 +99,7 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate)
if (img) {
cur_img = img;
+ cpu_timer_stop(&timer);
return img;
}
http://repo.or.cz/w/gfxprim.git/commit/9495fa1e62cd01f4dbbab631abcdc5ff0114…
commit 9495fa1e62cd01f4dbbab631abcdc5ff0114c49d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 21:44:36 2014 +0100
loaders: JPG: Fix two bugs.
* The fill_input_buffer() should use return from read not the buffer size
* The skip_input_data() should at least print warning if Seek failed
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index 9d19d9c2..a0eabd97 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -161,18 +161,22 @@ static boolean fill_input_buffer(struct jpeg_decompress_struct *cinfo)
}
src->mgr.next_input_byte = src->buffer;
- src->mgr.bytes_in_buffer = src->size;
+ src->mgr.bytes_in_buffer = ret;
return 1;
}
static void skip_input_data(struct jpeg_decompress_struct *cinfo, long num_bytes)
{
struct my_source_mgr* src = (void*)cinfo->src;
+ off_t ret;
GP_DEBUG(3, "Skipping %li bytes", num_bytes);
if (src->mgr.bytes_in_buffer < (unsigned long)num_bytes) {
- GP_IOSeek(src->io, num_bytes - src->mgr.bytes_in_buffer, GP_IO_SEEK_CUR);
+ ret = GP_IOSeek(src->io, num_bytes - src->mgr.bytes_in_buffer, GP_IO_SEEK_CUR);
+ //TODO: Call jpeg error
+ if (ret == (off_t)-1)
+ GP_FATAL("Failed to skip data: %s", strerror(errno));
src->mgr.bytes_in_buffer = 0;
} else {
src->mgr.bytes_in_buffer -= num_bytes;
-----------------------------------------------------------------------
Summary of changes:
build/syms/Loaders_symbols.txt | 3 +
demos/spiv/image_loader.c | 3 +
demos/spiv/spiv.1 | 2 +-
demos/spiv/spiv.c | 4 +-
demos/spiv/spiv_help.c | 2 +-
doc/backends.txt | 6 +-
doc/blits.txt | 2 +-
doc/context.txt | 2 +-
doc/debug.txt | 2 +-
doc/environment_variables.txt | 2 +-
doc/filters.txt | 10 +
include/core/GP_Core.h | 4 +-
include/core/GP_Debug.h | 2 +-
include/input/GP_EventQueue.h | 2 +-
include/loaders/GP_Container.h | 4 +-
include/loaders/{GP_PSP.h => GP_IOZlib.h} | 36 ++---
include/loaders/GP_Loaders.h | 2 +
libs/loaders/GP_IOZlib.c | 258 +++++++++++++++++++++++++++++
libs/loaders/GP_JPG.c | 8 +-
libs/loaders/GP_PNG.c | 5 +-
libs/loaders/GP_ZIP.c | 213 ++++++------------------
pylib/gfxprim/core/core.i | 3 +-
22 files changed, 366 insertions(+), 209 deletions(-)
copy include/loaders/{GP_PSP.h => GP_IOZlib.h} (69%)
create mode 100644 libs/loaders/GP_IOZlib.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
18 Mar '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 c4cb658954c2cd3de44939d096b48eb40438d674 (commit)
via 623d537b03153f26c9e6cc0d68d7dfa70fb62058 (commit)
via e78aa462e49f391bc0cf7fc31bde121063e23f2c (commit)
via 556a69a3e1bb48998da72d810b8daec1af997f49 (commit)
via 9bf5488c204dba601b1f43ab1a20542207f194be (commit)
from 05ec5cc78e822d2d4d45b54280997526d5e1bd64 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/c4cb658954c2cd3de44939d096b48eb40438…
commit c4cb658954c2cd3de44939d096b48eb40438d674
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Mar 18 23:31:08 2014 +0100
loaders: zip: Partial support for stream zip
Some zip files does not have crc, compressed size and uncompressed size
in zip local header but in data descriptor (which is located after the
data).
This commit modifies the decompression rutines to cope with unknown
buffer size (the buffer is reallocated on the fly).
Seeking in the ZIP does not work yet.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index 11e3eed6..7928023d 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -177,30 +177,50 @@ struct deflate_inbuf {
struct deflate_outbuf {
uint32_t crc;
uint32_t size;
+ uint32_t fill;
uint8_t *buf;
};
static unsigned deflate_in(void *in_desc, unsigned char **buf)
{
struct deflate_inbuf *in = in_desc;
- int chunk = in->to_read >= CHUNK ? CHUNK : in->to_read;
+ int chunk, ret;
- if (GP_IORead(in->io, in->buf, chunk) != chunk)
- return 0;
+ if (in->to_read)
+ chunk = in->to_read >= CHUNK ? CHUNK : in->to_read;
+ else
+ chunk = CHUNK;
+
+ ret = GP_IORead(in->io, in->buf, chunk);
+
+ if (ret <= 0)
+ return ret;
*buf = in->buf;
- in->to_read -= chunk;
- return chunk;
+ if (in->to_read)
+ in->to_read -= ret;
+
+ return ret;
}
+#define BUFINC (1024 * 128)
+
static int deflate_out(void *out_desc, unsigned char *buf, unsigned len)
{
struct deflate_outbuf *out = out_desc;
+ if (out->fill + len >= out->size) {
+ out->buf = realloc(out->buf, out->size + GP_MAX(len, BUFINC));
+ if (!out->buf)
+ return 1;
+ out->size += GP_MAX(len, BUFINC);
+ GP_DEBUG(1, "Realloc %u %p", out->size, out->buf);
+ }
+
out->crc = crc32(out->crc, buf, len);
- memcpy(out->buf + out->size, buf, len);
- out->size += len;
+ memcpy(out->buf + out->fill, buf, len);
+ out->fill += len;
return 0;
}
@@ -210,16 +230,12 @@ static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio)
uint8_t *window;
int err = 0, ret;
uint8_t *buf;
-
- if (header->flags & FLAG_ZERO_SIZE_CRC) {
- GP_DEBUG(1, "Size not set in local file header");
- return ENOSYS;
- }
+ unsigned int bufsize = header->uncomp_size ? header->uncomp_size : BUFINC;
window = malloc(32 * 1024);
//TODO: Unsafe
- buf = malloc(header->uncomp_size);
+ buf = malloc(bufsize);
if (!window || !buf) {
err = ENOMEM;
@@ -242,7 +258,8 @@ static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio)
struct deflate_outbuf outbuf = {
.crc = crc32(0, NULL, 0),
- .size = 0,
+ .size = bufsize,
+ .fill = 0,
.buf = buf,
};
@@ -260,13 +277,31 @@ static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio)
goto err2;
}
+ if (header->flags & FLAG_ZERO_SIZE_CRC) {
+ GP_DEBUG(2, "In buffer %i, seeking back", strm.avail_in);
+ GP_IOSeek(io, -(int)strm.avail_in, GP_IO_SEEK_CUR);
+ uint16_t data_desc_header[] = {
+ 'P', 'K', 0x07, 0x08, /* Data desc header */
+ GP_IO_L4, /* CRC */
+ GP_IO_L4, /* Compressed size */
+ GP_IO_L4, /* Uncompressed size */
+ GP_IO_END
+ };
+
+ if (GP_IOReadF(io, data_desc_header, &header->crc,
+ &header->comp_size, &header->uncomp_size) != 7) {
+ GP_DEBUG(1, "Failed to read Data Description Header");
+ goto err2;
+ }
+ }
+
if (outbuf.crc != header->crc) {
GP_DEBUG(1, "CRC does not match");
err = EIO;
goto err2;
}
- if (outbuf.size != header->uncomp_size) {
+ if (outbuf.fill != header->uncomp_size) {
GP_DEBUG(1, "Decompressed size does not match");
err = EIO;
goto err2;
@@ -282,7 +317,7 @@ err2:
inflateBackEnd(&strm);
err1:
free(window);
- free(buf);
+ free(outbuf.buf);
return err;
}
http://repo.or.cz/w/gfxprim.git/commit/623d537b03153f26c9e6cc0d68d7dfa70fb6…
commit 623d537b03153f26c9e6cc0d68d7dfa70fb62058
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Mar 18 19:42:20 2014 +0100
loaders: zip: Add flag defs.
Add flags definitions and print them to debug output.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index ec80e963..11e3eed6 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -73,11 +73,9 @@ struct zip_priv {
struct zip_chunks_table table;
};
-#define GEN_FLAG_ENCRYPTED 0x01
-
struct zip_local_header {
uint16_t ver;
- uint16_t bit_flags;
+ uint16_t flags;
uint16_t comp_type;
uint32_t crc;
@@ -130,6 +128,27 @@ static const char *compress_method_name(enum compress_method comp)
return compress_method_names[comp];
}
+enum zip_flags {
+ /* File is encrypted */
+ FLAG_ENCRYPTED = 0x0001,
+ /* Size and CRC are in data descriptor after the compressed data */
+ FLAG_ZERO_SIZE_CRC = 0x0008,
+ /* Filename and comment fileds are in UTF-8 */
+ FLAG_UTF8 = 0x0800,
+};
+
+static void print_flags(struct zip_local_header *header)
+{
+ if (header->flags & FLAG_ENCRYPTED)
+ GP_DEBUG(2, "File is encrypted");
+
+ if (header->flags & FLAG_ZERO_SIZE_CRC)
+ GP_DEBUG(2, "File size and CRC are after compressed data");
+
+ if (header->flags & FLAG_UTF8)
+ GP_DEBUG(2, "Filename and comment are encoded in UTF-8");
+}
+
static int seek_bytes(GP_IO *io, uint32_t bytes)
{
if (bytes == 0)
@@ -192,7 +211,13 @@ static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio)
int err = 0, ret;
uint8_t *buf;
+ if (header->flags & FLAG_ZERO_SIZE_CRC) {
+ GP_DEBUG(1, "Size not set in local file header");
+ return ENOSYS;
+ }
+
window = malloc(32 * 1024);
+
//TODO: Unsafe
buf = malloc(header->uncomp_size);
@@ -307,7 +332,7 @@ static int zip_load_header(GP_IO *io, struct zip_local_header *header)
};
ret = GP_IOReadF(io, zip_local_header,
- &header->ver, &header->bit_flags, &header->comp_type,
+ &header->ver, &header->flags, &header->comp_type,
&header->crc, &header->comp_size, &header->uncomp_size,
&header->fname_len, &header->extf_len);
@@ -334,7 +359,9 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
header.ver/10, header.ver%10,
compress_method_name(header.comp_type));
- if (header.bit_flags & GEN_FLAG_ENCRYPTED) {
+ print_flags(&header);
+
+ if (header.flags & FLAG_ENCRYPTED) {
GP_DEBUG(1, "Can't handle encrypted files");
err = ENOSYS;
goto out;
http://repo.or.cz/w/gfxprim.git/commit/e78aa462e49f391bc0cf7fc31bde121063e2…
commit e78aa462e49f391bc0cf7fc31bde121063e23f2c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 16 21:51:13 2014 +0100
doc: Update compilation instructions
* Add links to libraries
* Add packages section
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/compilation.txt b/doc/compilation.txt
index b5eb7fc4..35f8bd8a 100644
--- a/doc/compilation.txt
+++ b/doc/compilation.txt
@@ -3,33 +3,35 @@ Dependencies
*Base dependencies*
-* C compiler (tested with 'gcc' or 'clang')
-* GNU make
-* Python (2.6 or newer)
-* Jinja2
+* C compiler (tested with link:http://gcc.gnu.org/[gcc] and
+ link:http://clang.llvm.org/[clang])
+* link:https://www.gnu.org/software/make/[GNU make]
+* link:https://www.python.org/[Python] (2.6 or newer)
+* link:http://jinja.pocoo.org/docs/[Jinja2]
*Optional Image loaders*
* libjpeg
-* libpng
-* giflib
-* libtiff
-* openjpeg >= 2.0.0
-* zlib (usually installed as libpng dependency)
+* link:http://www.libpng.org/[libpng]
+* link:http://sourceforge.net/projects/giflib/[giflib]
+* link:http://www.remotesensing.org/libtiff/[libtiff]
+* link:http://code.google.com/p/openjpeg/[openjpeg] >= 2.0.0
+* link:http://www.zlib.net/[zlib] (usually installed as libpng dependency)
*Optinal Text rendering*
-* FreeType
+* link:http://www.freetype.org/[FreeType]
*Optional Backends*
* X11
-* AA-lib
-* SDL-1.2 (not recomended, known to be slow and buggy)
+* link:http://aa-project.sourceforge.net/aalib/[AA-lib]
+* link:http://www.libsdl.org/[SDL] 1.2
+ (not recomended, known to be slow and buggy)
*Python Bindings*
-* Swig
+* link:http://www.swig.org/[Swig]
* Python (devel library)
Compilation
@@ -61,7 +63,7 @@ The +make install+ command will install GFXprim libraries and devel headers
into your system.
OpenSUSE & Fedora
------------------
+~~~~~~~~~~~~~~~~~
Instruction to install required packages on
link:http://www.opensuse.org/[OpenSUSE].
@@ -102,7 +104,7 @@ zypper in gcc make python-Jinja2 libjpeg-devel libpng-devel giflib-devel
-------------------------------------------------------------------------------
Debian
-------
+~~~~~~
Instruction to install required packages on link:http://www.debian.org[Debian]
and other Debian based distributions.
@@ -138,3 +140,27 @@ apt-get install gcc make python-jinja2 libjpeg-dev libpng-dev libgif-dev
libtiff-dev libfreetype6-dev libx11-dev libxext-dev swig
python-dev
-------------------------------------------------------------------------------
+
+Packages
+--------
+
+RPM
+~~~
+RPM packages as well as specfile are available in
+link:https://build.opensuse.org/package/show/home:metan/gfxprim[build service].
+
+Deb
+~~~
+Deb packages can be build from the GFXprim source (after installing necessary
+devel packages) by:
+
+.Building debian packages
+-------------------------------------------------------------------------------
+# apt-get install devscripts
+# cd gfxprim
+# debuild -i -us -uc
+-------------------------------------------------------------------------------
+
+Gentoo
+~~~~~~
+GFXprim source contains ebuild in 'gentoo/' directory.
http://repo.or.cz/w/gfxprim.git/commit/556a69a3e1bb48998da72d810b8daec1af99…
commit 556a69a3e1bb48998da72d810b8daec1af997f49
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 16 21:19:48 2014 +0100
doc: Remove '' from emphasized words, fixes.
* NULL, stderr, stdout... are now emphasized by default
* A few fixes
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/backends.txt b/doc/backends.txt
index 4196c8f8..9b0c392c 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -124,9 +124,9 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
enum GP_BackendX11Flags flags);
-------------------------------------------------------------------------------
-Returns pointer to initialized X11 backend or in case of failure 'NULL'.
+Returns pointer to initialized X11 backend or in case of failure NULL.
-When display is 'NULL' default display is used (which is what you want most of the
+When display is NULL default display is used (which is what you want most of the
time).
This backends supports multiple windows. Each time you call the initialization
@@ -217,11 +217,11 @@ The 'caption' string is used for window caption, in case of X11 backend or may
be ignored completly in case of framebuffer backend.
If 'params' is set to '"help"' help for all backends is printed into the
-'stderr'.
+stderr.
If initialization was successful pointer to allocated and initialized backend
-is returned otherwise 'NULL' is returned and some helpful information should
-be printed into the 'stderr'.
+is returned otherwise NULL is returned and some helpful information should
+be printed into the stderr.
General Backend API
@@ -458,7 +458,7 @@ Adds a link:input.html#Timers[timer] to the backend timer queue.
Timers added to the backend are processed automatically while you call any of
backend 'Poll' or 'Wait' functions.
-If timer callback is set to 'NULL' a timer event is pushed to the backend
+If timer callback is set to NULL a timer event is pushed to the backend
input queue once timer has expired otherwise timer callback is called.
TIP: For example usage see backend timers
diff --git a/doc/context.txt b/doc/context.txt
index b8213ffe..c59c714e 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -44,8 +44,8 @@ lines (i.e. each image line starts at whole byte and ends at whole byte).
The 'pixels' array starts exactly at upper left corner of the image and is
stored in horizontal lines (each line contains 'w' pixels and there is 'h'
-lines). Each line is 'bytes_per_row' bytes long (which equals to 'w' * 'bpp' /
-8 rouned up to the whole bytes). The first pixel may actually start at
+lines). Each line is 'bytes_per_row' bytes long (which equals to 'w * bpp /
+8' rouned up to the whole bytes). The first pixel may actually start at
'offset' bit in the first byte in each line (but only for some
<<Sub_Context,subcontexts>> for pixel types that are not byte aligned).
@@ -153,7 +153,7 @@ parameters are set to the default values (i.e. rotation flags are all set to
zero, 'free_pixels' flag is not set). Number of bits per pixel and
bytes per row are computed from the given pixel type and size.
-The 'pixels' pointer can be 'NULL' and can be changed later manually (the call
+The 'pixels' pointer can be NULL and can be changed later manually (the call
will *not* try to allocate the pixel memory automatically).
The function returns a pointer to the initialized context (i.e. the same
@@ -224,7 +224,7 @@ Frees the context memory.
If 'free_pixels' flag is set, the pixels buffer is freed too.
-If gamma pointer is not 'NULL' the 'GP_GammaRelease()' is called.
+If gamma pointer is not NULL the 'GP_GammaRelease()' is called.
[[Sub_Context]]
Subcontext
diff --git a/doc/debug.txt b/doc/debug.txt
index 7424064f..e5f0015e 100644
--- a/doc/debug.txt
+++ b/doc/debug.txt
@@ -69,7 +69,7 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line,
Printf-like macros used to print debug messages. All of them calls the
'GP_DebugPrint()' function with slightly different parameters.
-NOTE: 'GP_DebugPrint()' function preserves 'errno'.
+NOTE: 'GP_DebugPrint()' function preserves errno.
[source,c]
-------------------------------------------------------------------------------
@@ -101,7 +101,7 @@ void GP_SetDebugHandler(void (*handler)(const struct GP_DebugMsg *msg));
-------------------------------------------------------------------------------
-By default debug messages are printed into the 'stderr' you can redirect them
+By default debug messages are printed into the stderr you can redirect them
to your debug handler by this function.
NOTE: For more information see debug message handler
diff --git a/doc/environment_variables.txt b/doc/environment_variables.txt
index 26d72095..85b6758d 100644
--- a/doc/environment_variables.txt
+++ b/doc/environment_variables.txt
@@ -37,7 +37,7 @@ messages are printed. Current the maximum used in GFXprim sources is 4, this
may change in the future. Use 'GP_DEBUG=10' to enable all debug messages for
sure.
-The output is, by default, written to 'stderr' and will look like:
+The output is, by default, written to stderr and will look like:
------------------------------------------------------------------------------
1: GP_Debug.c:GP_DebugPrint():67: Using debug level GP_DEBUG=10 from enviroment variable
1: GP_Debug.c:GP_DebugPrint():71: GFXprim library version 1.0.0-rc0
diff --git a/doc/event_queue.txt b/doc/event_queue.txt
index 5b476bd8..b694dc79 100644
--- a/doc/event_queue.txt
+++ b/doc/event_queue.txt
@@ -46,7 +46,7 @@ The initialization functions takes pointer to a memory large enough to hold an
event queue structure and array of queue_size events.
The last function allocates and initializes an event queue. If allocation has
-failed 'NULL' is returned.
+failed NULL is returned.
[source,c]
-------------------------------------------------------------------------------
@@ -153,5 +153,5 @@ void GP_EventQueuePush(struct GP_EventQueue *self,
-------------------------------------------------------------------------------
Following functions are used for puting events into the event queue. If
-pointer to the timeval structure is 'NULL' the event 'time' will be filled
+pointer to the timeval structure is NULL the event 'time' will be filled
with exact time the event was added to the queue.
diff --git a/doc/filters.txt b/doc/filters.txt
index 8cedbf9b..1ed37f09 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -22,12 +22,12 @@ For convenience, the filters API is unified:
* And the last argument is link:progress_callback.html[progress callback]
When using allocating version of the filter, pointer to the newly allocated
-context is returned, or in case of failure 'NULL' is returned.
+context is returned, or in case of failure NULL is returned.
-If 'malloc()' has failed 'NULL' is returned.
+If 'malloc()' has failed NULL is returned.
If filter has been interrupted by a callback, all allocated memory is freed,
-and 'NULL' is returned.
+and NULL is returned.
When using non-allocating variant of the filter, the destination context must
have correct pixel type and the size must be big enough to store the result.
diff --git a/doc/filters_dithering.txt b/doc/filters_dithering.txt
index 2f2605b3..94c82033 100644
--- a/doc/filters_dithering.txt
+++ b/doc/filters_dithering.txt
@@ -52,11 +52,11 @@ GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src,
Returns pointer to allocated context of given pixel_type.
-If 'malloc(2)' has failed, or operation was aborted by a callback 'NULL' is
+If 'malloc(2)' has failed, or operation was aborted by a callback NULL is
returned.
Not all pixel types all supported. If particular combination is not supported
-the function returns 'NULL' and sets errno to 'ENOSYS'.
+the function returns NULL and sets errno to 'ENOSYS'.
Hilbert-Peano
~~~~~~~~~~~~~
@@ -85,7 +85,7 @@ destination must be at least as large as source.
If operation was aborted by a callback, non-zero is returned.
Not all pixel types all supported. If particular combination is not supported
-the function returns 'NULL' and sets errno to 'ENOSYS'.
+the function returns NULL and sets errno to 'ENOSYS'.
[source,c]
-------------------------------------------------------------------------------
@@ -100,11 +100,11 @@ GP_Context *GP_FilterHilbertPeanoAlloc(const GP_Context *src,
Returns pointer to allocated context of given pixel_type.
-If 'malloc(2)' has failed, or operation was aborted by a callback 'NULL' is
+If 'malloc(2)' has failed, or operation was aborted by a callback NULL is
returned.
Not all pixel types all supported. If particular combination is not supported
-the function returns 'NULL' and sets errno to 'ENOSYS'.
+the function returns NULL and sets errno to 'ENOSYS'.
include::images/convert/images.txt[]
include::images/floyd_steinberg/images.txt[]
diff --git a/doc/filters_python.txt b/doc/filters_python.txt
index 19d50cf8..c1dadb84 100644
--- a/doc/filters_python.txt
+++ b/doc/filters_python.txt
@@ -8,7 +8,7 @@ The filter functions could be called directly as +filters.Foo(img, ..)+ or
from submodule as +img.filters.Foo(..)+. Note that in the second case the
image is passed automatically as a first parameter.
-If filter has been aborted from callback 'OSError' with 'errno' set to
+If filter has been aborted from callback 'OSError' with errno set to
'ECANCELED' is raised, see progress callback
link:core_python.html#Progress_Callback[documentation] for more information.
diff --git a/doc/filters_resize.txt b/doc/filters_resize.txt
index 03310775..6cf65644 100644
--- a/doc/filters_resize.txt
+++ b/doc/filters_resize.txt
@@ -42,15 +42,15 @@ The +GP_FilterReize()+ function resizes 'src' to fit 'dst' exactly.
Both 'src' and 'dst' must have the same pixel type.
-Returns zero on success, non-zero on failure and sets 'errno'.
+Returns zero on success, non-zero on failure and sets errno.
GP_FilterResizeAlloc
^^^^^^^^^^^^^^^^^^^^
The +GP_FilterResizeAlloc()+ allocates the destination give it's size.
-Returns pointer to newly allocated context or 'NULL' in case of failure and
-'errno' is set.
+Returns pointer to newly allocated context or NULL in case of failure and
+errno is set.
Nearest Neighbour Interpolation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/gamma.txt b/doc/gamma.txt
index 317900ae..a38518bd 100644
--- a/doc/gamma.txt
+++ b/doc/gamma.txt
@@ -109,7 +109,7 @@ Returns pointer to gamma table for particular pixel_type and gamma value.
The same gamma is used for all channels.
-May fail and return 'NULL' if 'malloc()' has failed.
+May fail and return NULL if 'malloc()' has failed.
[source,c]
-------------------------------------------------------------------------------
diff --git a/doc/grabbers.txt b/doc/grabbers.txt
index 06ff7913..21285921 100644
--- a/doc/grabbers.txt
+++ b/doc/grabbers.txt
@@ -124,5 +124,5 @@ that width and height, but the driver may return different values if chosen
width and height are not supported.
Returns either pointer to the initialized grabber or, in case of failure,
-'NULL' and 'errno' is set.
+NULL and errno is set.
diff --git a/doc/input.txt b/doc/input.txt
index 08b0816d..13299979 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -191,7 +191,7 @@ Event API
void GP_EventDump(struct GP_Event *ev);
-------------------------------------------------------------------------------
-The 'GP_EventDump' dumps event in human-readable format into the 'stdout'.
+The 'GP_EventDump' dumps event in human-readable format into the stdout.
[source,c]
-------------------------------------------------------------------------------
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 7d43aa8a..c1d94e8e 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -73,7 +73,7 @@ functions for each format that implements signature matching. If image
signature is recognized, image loader it is called and the result is returned.
If file extension disagrees with file signature (which is quite common on the
-internet) a warning is printed into the 'stderr'.
+internet) a warning is printed into the stderr.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
diff --git a/doc/loaders_io.txt b/doc/loaders_io.txt
index e12e7468..2e010bbc 100644
--- a/doc/loaders_io.txt
+++ b/doc/loaders_io.txt
@@ -57,7 +57,7 @@ case of failure a negative number (-1).
Return value from 'Close' is zero on success and non-zero on IO failure.
-NOTE: Make sure 'errno' is set if any of the operations has failed.
+NOTE: Make sure errno is set if any of the operations has failed.
[source,c]
-------------------------------------------------------------------------------
@@ -73,7 +73,7 @@ This is a wrapper to 'io->Read()'.
Reads at most 'size' bytes from an 'IO' stream and stores them into the
buffer. Returns number of bytes read.
-On failure the return value is negative and 'errno' is set.
+On failure the return value is negative and errno is set.
[source,c]
@@ -90,7 +90,7 @@ This is a wrapper to 'io->Write()'.
Writes at most 'size' bytes from an 'IO' stream and stores them into the
buffer. Returns number of bytes read.
-On failure the return value is negative and 'errno' is set.
+On failure the return value is negative and errno is set.
[source,c]
-------------------------------------------------------------------------------
@@ -106,7 +106,7 @@ This is a wrapper to 'io->Close()'.
Finalizes reading/writing, closes file descriptors (in case of file IO), frees
memory buffers.
-Returns zero on success, non-zero on IO failure and 'errno' is set.
+Returns zero on success, non-zero on IO failure and errno is set.
[source,c]
@@ -146,7 +146,7 @@ off_t GP_IORewind(GP_IO *io)
Wrapper to 'GP_IOSeek()', rewinds to the start of the IO stream.
-Returns zero on success, non-zero on failure and 'errno' is set.
+Returns zero on success, non-zero on failure and errno is set.
[source,c]
@@ -160,11 +160,11 @@ GP_IO *GP_IOMem(void *buf, size_t size, void (*free)(void *));
Creates an read-only IO from a memory buffer.
-Returns initialized IO or in case of failure 'NULL' and 'errno' is set.
+Returns initialized IO or in case of failure NULL and errno is set.
The 'buf' is pointer to the start of the buffer, the 'size' is size in bytes.
-The 'free()' callback if not 'NULL' is called with the start of the buffer as
+The 'free()' callback if not NULL is called with the start of the buffer as
an argument on 'IOClose()'.
TIP: See link:example_memory_io.html[memory IO example].
@@ -186,5 +186,5 @@ GP_IO *GP_IOFile(const char *path, enum GP_IOFileMode mode);
Creates an IO stream from a file.
-Returns a pointer to initialized IO stream, or in case of failure 'NULL' and
-'errno' is set.
+Returns a pointer to initialized IO stream, or in case of failure NULL and
+errno is set.
diff --git a/doc/loaders_python.txt b/doc/loaders_python.txt
index 6ffaaa6a..a73d1f0e 100644
--- a/doc/loaders_python.txt
+++ b/doc/loaders_python.txt
@@ -35,7 +35,7 @@ fails files signature is used.
|===============================================================================
| May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT' or any other
- 'errno' set by 'open(2)', 'read(2)', 'seek(2)'.
+ errno set by 'open(2)', 'read(2)', 'seek(2)'.
| May raise 'OSError' with errno set to 'ENOSYS' on unsupported or not recognized
format or if specific loader was disabled upon compilation.
@@ -71,7 +71,7 @@ For the Save() method the file format is derived from the extension.
|===============================================================================
| May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT', 'ENOSPC'
- or any other 'errno' set by 'open(2)', 'write(2)', 'seek(2)'.
+ or any other errno set by 'open(2)', 'write(2)', 'seek(2)'.
| May raise 'OSError' with errno set to 'ENOSYS' if pixel type is not supported
by the format or if the save method is not implemented (possibly disabled upon
compilation).
@@ -88,4 +88,4 @@ import gfxprim.loaders as loaders
-------------------------------------------------------------------------------
-Prints all loaders and their capabilites into the 'stdout'.
+Prints all loaders and their capabilites into the stdout.
diff --git a/doc/pixels.txt b/doc/pixels.txt
index 37553c47..ffc3fa1e 100644
--- a/doc/pixels.txt
+++ b/doc/pixels.txt
@@ -39,12 +39,12 @@ typedef enum GP_PixelType {
-------------------------------------------------------------------------------
-Pixels are described by a pixel type, which is enumeration type. The enum is
-defined in the generated 'GP_Pixel.gen.h' header and must contain at least the
-members listed above.
+Pixels are described by a pixel type, which is an enumeration type.
-The same names as are the enum values are also defined (to themselves) as
-macros so that it's possible to use them with 'ifdef'.
+The enum is defined in the 'GP_Pixel.gen.h' header link:gen.html[generated]
+from a configuration file.
+
+The header and must contain at least the members listed above.
[source,c]
-------------------------------------------------------------------------------
diff --git a/doc/progress_callback.txt b/doc/progress_callback.txt
index e12dccf2..9a0e50da 100644
--- a/doc/progress_callback.txt
+++ b/doc/progress_callback.txt
@@ -33,7 +33,7 @@ periodically and the percentage field is updated.
The return value from callback could abort the execution. If a non-zero value
is returned operation is aborted, all memory freed etc., in case of pixmap
-loaders 'errno' is set to 'ECANCELED' and in case of pixmap savers the newly
+loaders errno is set to 'ECANCELED' and in case of pixmap savers the newly
created file is removed too.
The callback, if supported, is the last parameter of a function.
diff --git a/doc/text.txt b/doc/text.txt
index 3acdd81e..3f3a5e70 100644
--- a/doc/text.txt
+++ b/doc/text.txt
@@ -42,7 +42,7 @@ GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style,
Draws text at the position x and y; the alignment of the text in relation
to the point is specified by alignment flags.
-If the 'style' argument is 'NULL', a default style is used.
+If the 'style' argument is NULL, a default style is used.
The text size can be computed by following functions:
http://repo.or.cz/w/gfxprim.git/commit/9bf5488c204dba601b1f43ab1a20542207f1…
commit 9bf5488c204dba601b1f43ab1a20542207f194be
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 16 21:17:02 2014 +0100
doc: Update loaders, add TIFF.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf
index cd6e25b3..8babf754 100644
--- a/doc/asciidoc.conf
+++ b/doc/asciidoc.conf
@@ -1,10 +1,14 @@
[specialwords]
-emphasizedwords=GFXprim
+emphasizedwords=GFXprim errno stdout stdin stderr NULL
[attributes]
# use image icons
icons
+# Redefine <<>> xref macro
+[xref2-inlinemacro]
+<a href="#{1}">{2={1}}</a>
+
[header]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
diff --git a/doc/asciidoc.css b/doc/asciidoc.css
index 09829b1f..a863bdb7 100644
--- a/doc/asciidoc.css
+++ b/doc/asciidoc.css
@@ -1,6 +1,6 @@
/* Default font. */
body {
- font-family: Georgia,serif;
+ font-family: Georgia,Serif;
background: #bbb;
}
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 2a257ca3..7d43aa8a 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -3,8 +3,9 @@ Context loaders
This part of GFXprim library implements API to load and save images for common
image file formats.
-Currently we support 'JPEG', 'PNG', 'BMP', 'TIFF' and 'PNM' images for loading
-and saving and 'GIF', 'JPEG2000', 'PCX', 'CBZ', 'PSD' and 'PSP' for loading.
+Currently we support <<JPEG>>, <<PNG>>, <<BMP>>, <<TIFF>> and <<PNM>> images for
+loading and saving and <<GIF>>, <<JPEG2000>>, <<PCX>>, 'CBZ', <<PSD>> and
+<<PSP>> for loading.
Have a look at the link:about.html#Loaders[supported formats] for more
detailed information.
@@ -16,7 +17,7 @@ Loading functions exists in at least two flavors. One that works with a path
to a file and one that reads data from an link:loaders_io.html[IO stream].
All loading functions returns a pointer to newly allocated and loaded image or
-upon a failure 'NULL' and 'errno' is set.
+upon a failure NULL and errno is set.
The link:context.html[Context] returned by the loaders should be later freed
with link:context.html#ContextFree[GP_ContextFree()].
@@ -29,17 +30,19 @@ The signature matching functions takes a 32 bytes long buffer and looks for a
valid link:signatures.html[image signature]. If signature is found non-zero is
returned.
-In case of a failure 'errno' is set, possible 'errno' values are:
-
-* anything returned by +open()+, +close()+, +lseek()+, +read()+, +write()+, ...
- - 'ENOENT' if file doesn't exist
- - 'EACCES' if process doesn't have rights
- - etc.
-
-* 'ENOSYS' if GFXprim wasn't compiled with particular library support
-* 'ENOMEM' if returned by +malloc()+
-* 'EIO', 'EINVAL' invalid image data (wrong signature, wrong or too short header or image data)
-* 'ECANCELED' action canceled by returning non-zero from within a callback
+.Possible errno values
+|===============================================================================
+| Any errno returned by underlying 'open()', 'close()', 'lseek()', 'read()',
+ 'write()', ...
+| 'ENOENT' if file doesn't exist
+| 'EACCES' if process doesn't have rights to open the file
+| 'ENOSYS' if GFXprim wasn't compiled with particular library support
+| 'ENOMEM' if returned by 'malloc()'
+| 'EIO', 'EINVAL' invalid image data (wrong signature, wrong or too short
+ header or image data)
+| 'ECANCELED' action canceled by returning non-zero from within a
+ link:progress_callback.html[callback].
+|===============================================================================
You can get more information about the error condition by turning on GFXprim
link:environment_variables.html#GP_DEBUG[debug messages].
@@ -90,13 +93,13 @@ Saves a link:context.html[Context] into a file.
The file format is matched accordingly to the file extension.
-If extension is not found non-zero is returned and 'errno' is set to 'EINVAL'.
+If extension is not found non-zero is returned and errno is set to 'EINVAL'.
If extension was found but support for saving the image format is not
-implemented 'errno' is set to 'ENOSYS' (this may happen in case that GFXprim
+implemented errno is set to 'ENOSYS' (this may happen in case that GFXprim
wasn't compiled with support for this image type).
-If context pixel type is not supported by the format 'errno' is set to
+If context pixel type is not supported by the format errno is set to
'EINVAL'.
[[Register_Loader]]
@@ -160,13 +163,13 @@ void GP_LoaderUnregister(GP_Loader *self);
The 'GP_Loader' structure describes an image loader.
-The 'Load', 'Save' and 'Match' functions could be 'NULL' if the particular
+The 'Load', 'Save' and 'Match' functions could be NULL if the particular
functionality is not implemented.
The 'fmt_name' is a short string that describes the format. For example:
'Netbpm portable pixmap'.
-The extensions is 'NULL'-terminated array of strings that holds all possible
+The extensions is NULL-terminated array of strings that holds all possible
extensions that are commonly used for this image format.
All internal loaders are all described in list of this structures which is
@@ -189,7 +192,7 @@ link:example_loader_registration.html[example].
const GP_Loader *GP_MatchSignature(const void *buf)
-------------------------------------------------------------------------------
-Returns pointer to image loader accordingly to image signature or 'NULL' if no
+Returns pointer to image loader accordingly to image signature or NULL if no
suitable loader was found. The buf pointer must point to a buffer at least 32
bytes long.
@@ -209,9 +212,11 @@ string after the dot) and matches it against known extensions.
WARNING: If you attempt to modify the content of the structure the behavior is
undefined. Most likely the program will crash.
+[[PNG]]
PNG Loader
~~~~~~~~~~
-The 'PNG' image support is implemented by the libpng library.
+The 'PNG' image support is implemented by the
+link:http://www.libpng.org/[libpng library].
[source,c]
-------------------------------------------------------------------------------
@@ -226,7 +231,7 @@ Reads a 'PNG' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
is expected to start exactly at the 'PNG' file signature.
Returns newly allocated context (containing decompressed image) or in case of
-failure 'NULL' and 'errno' is set.
+failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -243,7 +248,7 @@ GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback);
Loads a 'PNG' image from a file.
Returns a pointer to newly allocated loaded image, or in case of failure
-'NULL' and 'errno' is set.
+NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -259,7 +264,7 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
-------------------------------------------------------------------------------
Saves a link:context.html[Context] as a 'PNG' image, in case particular pixel
-type is not supported non-zero is returned and 'errno' is set to 'ENOSYS'.
+type is not supported non-zero is returned and errno is set to 'ENOSYS'.
Supports 'G1', 'G2', 'G4', 'G8', 'G16', and 8-bit 'RGB' and 'RGBA' pixel
types.
@@ -275,6 +280,7 @@ int GP_MatchPNG(const void *buf);
Matches a 'PNG' link:signatures.html[file signature]. Returns non-zero if found.
+[[JPEG]]
JPEG Loader
~~~~~~~~~~~
The 'JPEG' image support is implemented by the jpeg library.
@@ -292,7 +298,7 @@ Reads a 'JPEG' image from readable 'GP_IO'. The link:loaders_io.html[IO
stream] is expected to start exactly at the 'JPEG' file signature.
Returns newly allocated context (containing decompressed image) or in case of
-failure 'NULL' and 'errno' is set.
+failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -309,7 +315,7 @@ GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback);
Loads a 'JPEG' image from a file.
Returns a pointer to newly allocated loaded image, or in case of failure
-'NULL' and 'errno' is set.
+NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -340,6 +346,7 @@ int GP_MatchJPG(const void *buf);
Matches a 'JPEG' link:signatures.html[file signature]. Returns non-zero if
found.
+[[JPEG2000]]
JPEG 2000 Loader
~~~~~~~~~~~~~~~~
The 'JPEG 2000' image support is implemented using the openjpeg library.
@@ -357,7 +364,7 @@ Reads a 'JPEG2000' image from readable 'GP_IO'. The link:loaders_io.html[IO
stream] is expected to start exactly at the 'JPEG2000' file signature.
Returns newly allocated context (containing decompressed image) or in case of
-failure 'NULL' and 'errno' is set.
+failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -392,10 +399,12 @@ int GP_MatchJP2(const void *buf);
Matches a 'JPEG2000' link:signatures.html[file signature]. Returns non-zero if
found.
+[[GIF]]
GIF Loader
~~~~~~~~~~
-The 'GIF' image support is implemented by the giflib library.
+The 'GIF' image support is implemented using the
+link:http://sourceforge.net/projects/giflib/[giflib library].
[source,c]
-------------------------------------------------------------------------------
@@ -410,7 +419,7 @@ Reads a 'GIF' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
is expected to start exactly at the 'GIF' file signature.
Returns newly allocated context (containing decompressed image) or in case of
-failure 'NULL' and 'errno' is set.
+failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -443,6 +452,7 @@ int GP_MatchGIF(const void *buf);
Matches a 'GIF' link:signatures.html[file signature]. Returns non-zero if
found.
+[[BMP]]
BMP Loader
~~~~~~~~~~
@@ -462,7 +472,7 @@ Reads a 'BMP' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
is expected to start exactly at the 'BMP' file signature.
Returns newly allocated context (containing decompressed image) or in case of
-failure 'NULL' and 'errno' is set.
+failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -507,6 +517,77 @@ int GP_MatchBMP(const void *buf);
Matches a 'BMP' link:signatures.html[file signature]. Returns non-zero if
found.
+[[TIFF]]
+TIFF Loader
+~~~~~~~~~~~
+
+The 'TIFF' loader support is done using the
+link:http://www.remotesensing.org/libtiff/[tiff library].
+
+Currently only subset of 'tiff' images could be loaded, tiles does not work
+yet.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_TIFF.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_ReadTIFF(GP_IO *io, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Reads a 'TIFF' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
+is expected to start exactly at the 'TIFF' file signature.
+
+Returns newly allocated context (containing decompressed image) or in case of
+failure NULL and errno is set.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_TIFF.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Loads a 'TIFF' image from a file.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_TIFF.h>
+/* or */
+#include <GP.h>
+
+int GP_SaveTIFF(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Saves a link:context.html[Context] as a 'TIFF' image.
+
+Supports 'G1', 'G2', 'G4' and 'G8' grayscale and 8-bit 'RGB' pixel types.
+
+The image is saved in stripes.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_TIFF.h>
+/* or */
+#include <GP.h>
+
+int GP_MatchTIFF(const void *buf);
+-------------------------------------------------------------------------------
+
+Matches a 'TIFF' link:signatures.html[file signature]. Returns non-zero if
+found.
+
+[[PSP]]
PSP Loader
~~~~~~~~~~
@@ -526,7 +607,7 @@ link:loaders_io.html[IO stream] is expected to start exactly at the 'PSP' file
signature.
Returns newly allocated context (containing decompressed image) or in case of
-failure 'NULL' and 'errno' is set.
+failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -557,6 +638,7 @@ int GP_MatchPSP(const void *buf);
Matches a 'PSP' link:signatures.html[file signature]. Returns non-zero if
found.
+[[PSD]]
PSD Loader
~~~~~~~~~~
@@ -578,7 +660,7 @@ Reads a 'PSD' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
is expected to start exactly at the 'PSD' file signature.
Returns newly allocated context (containing decompressed image) or in case of
-failure 'NULL' and 'errno' is set.
+failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
@@ -597,7 +679,7 @@ Loads a merged image (if present) from a 'PSD' file.
Fallbacks to thumbnail if merged image is not present or has unsupported pixel
type.
-Returns 'NULL' (TODO ERRNO) if merged image is not present/supported and
+Returns NULL (TODO ERRNO) if merged image is not present/supported and
thumbnail is not present either.
The resulting link:context.html[Context] should be later freed with
@@ -615,6 +697,7 @@ int GP_MatchPSD(const void *buf);
Matches a 'PSD' link:signatures.html[file signature]. Returns non-zero if
found.
+[[PNM]]
PNM Loaders
~~~~~~~~~~~
@@ -734,6 +817,7 @@ The 'PNM' matches all of the formats. i.e. 'PBM', 'PGM' and 'PPM'.
All functions return non-zero if found.
+[[PCX]]
PCX Loader
~~~~~~~~~~
@@ -752,7 +836,7 @@ Reads a 'PCX' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
is expected to start exactly at the 'PCX' file signature.
Returns newly allocated context (containing decompressed image) or in case of
-failure 'NULL' and 'errno' is set.
+failure NULL and errno is set.
The resulting link:context.html[Context] should be later freed with
link:context.html#ContextFree[GP_ContextFree()].
-----------------------------------------------------------------------
Summary of changes:
doc/asciidoc.conf | 6 ++-
doc/asciidoc.css | 2 +-
doc/backends.txt | 12 ++--
doc/compilation.txt | 56 +++++++++++----
doc/context.txt | 8 +-
doc/debug.txt | 4 +-
doc/environment_variables.txt | 2 +-
doc/event_queue.txt | 4 +-
doc/filters.txt | 6 +-
doc/filters_dithering.txt | 10 ++--
doc/filters_python.txt | 2 +-
doc/filters_resize.txt | 6 +-
doc/gamma.txt | 2 +-
doc/grabbers.txt | 2 +-
doc/input.txt | 2 +-
doc/loaders.txt | 154 +++++++++++++++++++++++++++++++---------
doc/loaders_io.txt | 18 +++---
doc/loaders_python.txt | 6 +-
doc/pixels.txt | 10 ++--
doc/progress_callback.txt | 2 +-
doc/text.txt | 2 +-
libs/loaders/GP_ZIP.c | 94 +++++++++++++++++++++----
22 files changed, 293 insertions(+), 117 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
14 Mar '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 05ec5cc78e822d2d4d45b54280997526d5e1bd64 (commit)
from c2fb0ec9b8d440b7128d76344907b20ad292885e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/05ec5cc78e822d2d4d45b54280997526d5e1…
commit 05ec5cc78e822d2d4d45b54280997526d5e1bd64
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Mar 14 00:13:22 2014 +0100
doc: loaders: Fixed + add signatures.txt
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/Makefile b/doc/Makefile
index ac8868c2..2b56050d 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -5,7 +5,7 @@ SOURCES=index.html about.txt context.txt loaders.txt filters.txt get_put_pixel.txt blits.txt progress_callback.txt text.txt event_queue.txt compilation.txt filters_resize.txt filters_dithering.txt filters_python.txt spiv.txt core_common.txt - convert.txt news_1_0_0-rc1.txt loaders_io.txt
+ convert.txt news_1_0_0-rc1.txt loaders_io.txt signatures.txt
SOURCES+=core_python.txt gfx_python.txt loaders_python.txt backends_python.txt
diff --git a/doc/context.txt b/doc/context.txt
index 0d42abde..b8213ffe 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -210,6 +210,7 @@ flags are set to zero.
The 'free_pixels' flag for the resulting context is set.
+[[ContextFree]]
[source,c]
-------------------------------------------------------------------------------
#include <core/GP_Context.h>
diff --git a/doc/loaders.txt b/doc/loaders.txt
index af588cb9..2a257ca3 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -1,28 +1,33 @@
Context loaders
---------------
-This part of GFXprim library aims to create API to load and save images
-from/to common image file formats.
+This part of GFXprim library implements API to load and save images for common
+image file formats.
Currently we support 'JPEG', 'PNG', 'BMP', 'TIFF' and 'PNM' images for loading
-and saving and 'GIF', 'JPEG2000' and 'PSP' for loading.
+and saving and 'GIF', 'JPEG2000', 'PCX', 'CBZ', 'PSD' and 'PSP' for loading.
-Have a look at the link:about.html#Loaders[supported formats].
+Have a look at the link:about.html#Loaders[supported formats] for more
+detailed information.
Image Loaders and Savers
~~~~~~~~~~~~~~~~~~~~~~~~
-All loading functions exists in at least two flavors. One that works with a
-path to a file and one that reads from an link:loaders_io.html[IO stream].
+Loading functions exists in at least two flavors. One that works with a path
+to a file and one that reads data from an link:loaders_io.html[IO stream].
-All loading functions returns a pointer to newly allocated and loaded image
-or upon a failure 'NULL' and 'errno' is set.
+All loading functions returns a pointer to newly allocated and loaded image or
+upon a failure 'NULL' and 'errno' is set.
-All saving functions returns zero on success and non-zero on failure. If
-image saving is aborted by a callback, the opened file is closed and removed
-from a file-system before the call returns.
+The link:context.html[Context] returned by the loaders should be later freed
+with link:context.html#ContextFree[GP_ContextFree()].
-The signature matching functions takes a 32 bytes long buffer and looks for a
-valid image signature. If signature is found non-zero is returned.
+All saving functions returns zero on success and non-zero on failure. If image
+saving is aborted by a callback, the opened file is closed and removed from a
+file-system before the call returns.
+
+The signature matching functions takes a 32 bytes long buffer and looks for a
+valid link:signatures.html[image signature]. If signature is found non-zero is
+returned.
In case of a failure 'errno' is set, possible 'errno' values are:
@@ -39,6 +44,9 @@ In case of a failure 'errno' is set, possible 'errno' values are:
You can get more information about the error condition by turning on GFXprim
link:environment_variables.html#GP_DEBUG[debug messages].
+General interface
+^^^^^^^^^^^^^^^^^
+
[[Load_Image]]
[source,c]
-------------------------------------------------------------------------------
@@ -51,19 +59,21 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback);
Loads an image from a file.
-The image format is first guessed by the file extension. If loader for the
-file extension is found it's called and if it succeeds the image data is
-returned.
+The image format is first guessed by the file extension. If loader is found
+and if it succeeds to load the image the newly loaded image is returned.
If file extension based guess fails either because the extension wasn't
-matched or if the loader for the extension failed; the signature based method
-is used. The loader loads several bytes (currently 32) from the file and
-calls signature matching functions for each format that implements signature
-matching. If image signature is found image loader it is called and the result
-is returned.
+matched or if the loader for the extension failed; the
+link:signatures.html[file signature] based method is used. The loader loads
+several bytes (currently 32) from the file and calls signature matching
+functions for each format that implements signature matching. If image
+signature is recognized, image loader it is called and the result is returned.
+
+If file extension disagrees with file signature (which is quite common on the
+internet) a warning is printed into the 'stderr'.
-If file extension disagrees with file signature on the file format a warning
-is printed into the 'stderr'.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
[[Save_Image]]
[source,c]
@@ -76,7 +86,7 @@ int GP_SaveImage(GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves a context into a file.
+Saves a link:context.html[Context] into a file.
The file format is matched accordingly to the file extension.
@@ -90,8 +100,8 @@ If context pixel type is not supported by the format 'errno' is set to
'EINVAL'.
[[Register_Loader]]
-Advanced Loaders usage
-^^^^^^^^^^^^^^^^^^^^^^
+Advanced Interface
+^^^^^^^^^^^^^^^^^^
[source,c]
-------------------------------------------------------------------------------
@@ -218,6 +228,9 @@ is expected to start exactly at the 'PNG' file signature.
Returns newly allocated context (containing decompressed image) or in case of
failure 'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PNG.h>
@@ -232,6 +245,9 @@ Loads a 'PNG' image from a file.
Returns a pointer to newly allocated loaded image, or in case of failure
'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PNG.h>
@@ -242,8 +258,8 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves a 'Context' into a 'PNG' image, in case particular pixel type is not
-supported non-zero is returned and 'errno' is set to 'ENOSYS'.
+Saves a link:context.html[Context] as a 'PNG' image, in case particular pixel
+type is not supported non-zero is returned and 'errno' is set to 'ENOSYS'.
Supports 'G1', 'G2', 'G4', 'G8', 'G16', and 8-bit 'RGB' and 'RGBA' pixel
types.
@@ -257,7 +273,7 @@ types.
int GP_MatchPNG(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'PNG' file signature. Returns non-zero if found.
+Matches a 'PNG' link:signatures.html[file signature]. Returns non-zero if found.
JPEG Loader
~~~~~~~~~~~
@@ -278,6 +294,9 @@ stream] is expected to start exactly at the 'JPEG' file signature.
Returns newly allocated context (containing decompressed image) or in case of
failure 'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_JPG.h>
@@ -287,11 +306,14 @@ failure 'NULL' and 'errno' is set.
GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads an 'JPEG' image from a file.
+Loads a 'JPEG' image from a file.
Returns a pointer to newly allocated loaded image, or in case of failure
'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_JPG.h>
@@ -302,9 +324,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Writes a 'Context' into a 'JPEG' image. If aborted by a callback, the opened
-file is closed and removed before the call returns non-zero and 'errno' is set
-to 'ECANCELED'.
+Saves a link:context.html[Context] as a 'JPEG' image.
The 'JPEG' format could store either 'G8' or 8-bit 'RGB' pixel-types.
@@ -317,7 +337,8 @@ The 'JPEG' format could store either 'G8' or 8-bit 'RGB' pixel-types.
int GP_MatchJPG(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'JPEG' file signature. Returns non-zero if found.
+Matches a 'JPEG' link:signatures.html[file signature]. Returns non-zero if
+found.
JPEG 2000 Loader
~~~~~~~~~~~~~~~~
@@ -338,6 +359,9 @@ stream] is expected to start exactly at the 'JPEG2000' file signature.
Returns newly allocated context (containing decompressed image) or in case of
failure 'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
NOTE: Due to limitations of the openjpeg library progress callback does not work.
[source,c]
@@ -349,7 +373,10 @@ NOTE: Due to limitations of the openjpeg library progress callback does not work
GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads 'JPEG2000' image from a file.
+Loads a 'JPEG2000' image from a file.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
NOTE: Due to limitations of the openjpeg library progress callback does not work.
@@ -362,7 +389,8 @@ NOTE: Due to limitations of the openjpeg library progress callback does not work
int GP_MatchJP2(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'JPEG2000' file signature. Returns non-zero if found.
+Matches a 'JPEG2000' link:signatures.html[file signature]. Returns non-zero if
+found.
GIF Loader
~~~~~~~~~~
@@ -384,6 +412,9 @@ is expected to start exactly at the 'GIF' file signature.
Returns newly allocated context (containing decompressed image) or in case of
failure 'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
NOTE: Currently this function loads only first image from the 'GIF' container.
[source,c]
@@ -395,7 +426,10 @@ NOTE: Currently this function loads only first image from the 'GIF' container.
GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads 'GIF' image from a file.
+Loads a 'GIF' image from a file.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
[source,c]
-------------------------------------------------------------------------------
@@ -406,7 +440,8 @@ Loads 'GIF' image from a file.
int GP_MatchGIF(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'GIF' file signature. Returns non-zero if found.
+Matches a 'GIF' link:signatures.html[file signature]. Returns non-zero if
+found.
BMP Loader
~~~~~~~~~~
@@ -429,6 +464,9 @@ is expected to start exactly at the 'BMP' file signature.
Returns newly allocated context (containing decompressed image) or in case of
failure 'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_BMP.h>
@@ -438,7 +476,10 @@ failure 'NULL' and 'errno' is set.
GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads 'BMP' image from a file.
+Loads a 'BMP' image from a file.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
[source,c]
-------------------------------------------------------------------------------
@@ -450,9 +491,9 @@ int GP_SaveBMP(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Writes a 'Context' into a 'BMP' file.
+Saves a link:context.html[Context] as a 'BMP' image.
-Currently only 8-bit 'RGB' formats are supported.
+Currently only 8-bit 'RGB' pixel types are supported.
[source,c]
-------------------------------------------------------------------------------
@@ -463,7 +504,8 @@ Currently only 8-bit 'RGB' formats are supported.
int GP_MatchBMP(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'BMP' file signature. Returns non-zero if found.
+Matches a 'BMP' link:signatures.html[file signature]. Returns non-zero if
+found.
PSP Loader
~~~~~~~~~~
@@ -479,12 +521,16 @@ The 'PSP' loader can load a composite image from a Paint Shop Pro Image Files.
GP_Context *GP_ReadPSP(GP_IO *io, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Reads a 'PSP' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
-is expected to start exactly at the 'PSP' file signature.
+Reads a 'PSP' composite image from readable 'GP_IO'. The
+link:loaders_io.html[IO stream] is expected to start exactly at the 'PSP' file
+signature.
Returns newly allocated context (containing decompressed image) or in case of
failure 'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PSP.h>
@@ -496,6 +542,9 @@ GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback);
Loads a composite image from a 'PSP' file.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PSP.h>
@@ -505,7 +554,8 @@ Loads a composite image from a 'PSP' file.
int GP_MatchPSP(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'PSP' file signature. Returns non-zero if found.
+Matches a 'PSP' link:signatures.html[file signature]. Returns non-zero if
+found.
PSD Loader
~~~~~~~~~~
@@ -524,12 +574,15 @@ RGB).
GP_Context *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Reads a 'PSP' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
+Reads a 'PSD' image from readable 'GP_IO'. The link:loaders_io.html[IO stream]
is expected to start exactly at the 'PSD' file signature.
Returns newly allocated context (containing decompressed image) or in case of
failure 'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PSD.h>
@@ -547,6 +600,9 @@ type.
Returns 'NULL' (TODO ERRNO) if merged image is not present/supported and
thumbnail is not present either.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PSD.h>
@@ -556,7 +612,8 @@ thumbnail is not present either.
int GP_MatchPSD(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'PSD' file signature. Returns non-zero if found.
+Matches a 'PSD' link:signatures.html[file signature]. Returns non-zero if
+found.
PNM Loaders
~~~~~~~~~~~
@@ -567,6 +624,28 @@ PNM Loaders
/* or */
#include <GP.h>
+GP_Context *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback);
+
+GP_Context *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback);
+
+GP_Context *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback);
+
+GP_Context *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Reads a ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM' image from readable
+'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at
+the file signature.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PNM.h>
+/* or */
+#include <GP.h>
+
GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback);
GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback);
@@ -578,7 +657,10 @@ GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback);
Loads either ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM'.
-The 'PNM' can load all of them i.e. 'PBM', 'PGM' and 'PPM'.
+The 'PNM' loader can load all of them i.e. 'PBM', 'PGM' and 'PPM'.
+
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
[source,c]
-------------------------------------------------------------------------------
@@ -590,7 +672,7 @@ GP_Context *GP_SavePBM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves 'G1' (1 bit grayscale) image into ASCII 'PBM'.
+Saves 'G1' (1 bit grayscale) image as ASCII 'PBM'.
[source,c]
-------------------------------------------------------------------------------
@@ -602,7 +684,7 @@ GP_Context *GP_SavePGM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4 and 8 bit grayscale) image into ASCII
+Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4 and 8 bit grayscale) image as ASCII
'PGM'.
[source,c]
@@ -615,7 +697,7 @@ GP_Context *GP_SavePPM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Saves 'RGB888' (24 bit RGB) image into ASCII 'PPM'.
+Saves 'RGB888' (24 bit RGB) image as ASCII 'PPM'.
[source,c]
-------------------------------------------------------------------------------
@@ -628,7 +710,7 @@ GP_Context *GP_SavePNM(const GP_Context *src, const char *dst_path,
-------------------------------------------------------------------------------
Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4, 8 bit grayscale) or 'RGB888' (24 bit
-RGB) image into ASCII 'PNM'.
+RGB) image as ASCII 'PNM'.
[source,c]
-------------------------------------------------------------------------------
@@ -645,8 +727,8 @@ int GP_MatchPPM(const void *buf);
int GP_MatchPNM(const void *buf);
-------------------------------------------------------------------------------
-Matches either ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM' file
-signatures.
+Matches either ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM'
+link:signatures.html[file signatures].
The 'PNM' matches all of the formats. i.e. 'PBM', 'PGM' and 'PPM'.
@@ -672,6 +754,9 @@ is expected to start exactly at the 'PCX' file signature.
Returns newly allocated context (containing decompressed image) or in case of
failure 'NULL' and 'errno' is set.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PCX.h>
@@ -683,6 +768,9 @@ GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback);
Loads a 'PCX' image from a file.
+The resulting link:context.html[Context] should be later freed with
+link:context.html#ContextFree[GP_ContextFree()].
+
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PCX.h>
@@ -692,4 +780,5 @@ Loads a 'PCX' image from a file.
int GP_MatchPCX(const void *buf);
-------------------------------------------------------------------------------
-Matches a 'PCX' file signature. Returns non-zero if found.
+Matches a 'PCX' link:signatures.html[file signature]. Returns non-zero if
+found.
diff --git a/doc/signatures.txt b/doc/signatures.txt
new file mode 100644
index 00000000..fce2bf93
--- /dev/null
+++ b/doc/signatures.txt
@@ -0,0 +1,36 @@
+File signatures
+---------------
+
+File signature is a short well defined sequence of bytes usually situated at
+the beginning of the file.
+
+.Table of image file signatures used by GFXprim loaders
+[options="autowidth,header"]
+|=============================================================================
+| Extension | Format Name | Signature | Signature in Hex
+| *JPEG* | | | +0xff 0xd8 0xff+
+| *PNG* | Portable Network Graphics | +211PNGrn032n+ |
+ +89 50 4e 47 0d 0a 1a 0a+
+| *GIF* | Graphics Interchange Format | +GIF87a or GIF89a+ |
+| *BMP* | | +BM+ | +42 4d+
+| *TIFF* | Tagged Image File Format | +II*0 or MM0*+ | +49 49 2a 00 or
+ 4d 4d 2a 00+
+| *PSP* | Paint Shop Pro Image |
+ +Paint Shop Pro Image Filenx1a00000000+ |
+| *PSD* | Adobe Photoshop Image | +8BPS0x01+ |
+| *PBM* | Netpbm portable bitmap | +P1 or P4+ |
+| *PGM* | Netpbm portable graymap | +P2 or P5+ |
+| *PPM* | Netpbm portable pixmap | +P3 or P6+ |
+| *PNM* | Netpbm portable anymap | +P1, P2, P3, P4, P5, P6+ |
+| *JP2* | JPEG 2000 |
++000x0cjPx20x20x0dx0ax87x0a+ | +00 00 00 0c 6a 50 20 20 0d 0a 87 0a+
+| *PCX* | ZSoft PCX || +0a [01-05] 0x01 {01, 02, 04, 08}+
+| *CBZ* | Comic Book Archive (ZIP) | +PK0304+ |
+|=============================================================================
+
+
+Explanation
+~~~~~~~~~~~
+ * Signature strings are written in C string syntax
+ * The [A-B] denotes any number from interval
+ * The {A, B, C} denotes any number from the set
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile | 2 +-
doc/context.txt | 1 +
doc/loaders.txt | 199 +++++++++++++++++++++++++++++++++++++--------------
doc/signatures.txt | 36 ++++++++++
4 files changed, 182 insertions(+), 56 deletions(-)
create mode 100644 doc/signatures.txt
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0