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 84df46f7a343005a0edbb3a744e8a62a109864ea (commit) via d63cd2b2a46aacac0683b804d887a571a3a1a1a7 (commit) via fcb2c2cfccb1d7122b5d6683481ac7ed57fc59c2 (commit) via b71fd317db698aa14a847020003be950257ae83d (commit) via c440a1bcd759c147b8f2b6739f41f9f94159ce64 (commit) via 32b937c63052f6686b1d818744f172c8658d4be2 (commit) via e42857ad289d9333411766b2df90cffea906cf11 (commit) from 1109c295817003da4e1da28179040c3060dc1326 (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/84df46f7a343005a0edbb3a744e8a62a10986...
commit 84df46f7a343005a0edbb3a744e8a62a109864ea Author: Cyril Hrubis metan@ucw.cz Date: Sat Feb 7 22:24:13 2015 +0100
spiv: Implement EXIF autorotation
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 75af202..91b1a2a 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -309,7 +309,7 @@ static void update_display(struct loader_params *params, GP_Context *img, struct cpu_timer timer; GP_ProgressCallback callback = {.callback = image_loader_callback};
- switch (config.orientation) { + switch (config.combined_orientation) { case ROTATE_0: break; case ROTATE_90: @@ -324,6 +324,8 @@ static void update_display(struct loader_params *params, GP_Context *img, callback.priv = "Rotating image (270)"; img = GP_FilterRotate270Alloc(img, &callback); break; + default: + break; }
if (img == NULL) @@ -384,7 +386,7 @@ static void update_display(struct loader_params *params, GP_Context *img,
show_info(params, img, orig_img);
- if (config.orientation) + if (config.combined_orientation) GP_ContextFree(img);
GP_BackendFlip(backend); @@ -465,6 +467,39 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size return img; }
+static void exif_autorotate(void) +{ + GP_DataNode *orientation; + + config.combined_orientation = config.orientation; + + if (!config.exif_autorotate) + return; + + orientation = GP_DataStorageGetByPath(image_loader_get_meta_data(), + NULL, "/Exif/Orientation"); + if (!orientation) + return; + + switch (orientation->value.i) { + case GP_EXIF_UPPER_LEFT: + config.combined_orientation += ROTATE_0; + break; + case GP_EXIF_LOWER_RIGHT: + config.combined_orientation += ROTATE_180; + break; + case GP_EXIF_UPPER_RIGHT: + config.combined_orientation += ROTATE_90; + break; + case GP_EXIF_LOWER_LEFT: + config.combined_orientation += ROTATE_270; + break; + } + + if (config.combined_orientation > ROTATE_270) + config.combined_orientation -= ROTATE_360; +} + static float calc_img_size(struct loader_params *params, uint32_t img_w, uint32_t img_h, uint32_t win_w, uint32_t win_h) @@ -473,7 +508,9 @@ static float calc_img_size(struct loader_params *params, unsigned int max_win_w = config.max_win_w; unsigned int max_win_h = config.max_win_h;
- switch (config.orientation) { + exif_autorotate(); + + switch (config.combined_orientation) { case ROTATE_90: case ROTATE_270: GP_SWAP(win_w, win_h); @@ -488,7 +525,7 @@ static float calc_img_size(struct loader_params *params, win_w = GP_MIN(max_win_w, img_w * params->zoom_rat + 0.5); win_h = GP_MIN(max_win_h, img_h * params->zoom_rat + 0.5);
- switch (config.orientation) { + switch (config.combined_orientation) { case ROTATE_90: case ROTATE_270: GP_BackendResize(backend, win_h, win_w); @@ -527,7 +564,7 @@ static float calc_img_size(struct loader_params *params, win_h = rat * img_h + 0.5; }
- switch (config.orientation) { + switch (config.combined_orientation) { case ROTATE_90: case ROTATE_270: GP_BackendResize(backend, win_h, win_w); @@ -885,13 +922,13 @@ int main(int argc, char *argv[]) config.orientation++;
if (config.orientation > ROTATE_270) - config.orientation = 0; + config.orientation = ROTATE_0;
params.show_progress_once = 1; show_image(¶ms); break; case GP_KEY_E: - if (config.orientation > 0) + if (config.orientation > ROTATE_0) config.orientation--; else config.orientation = ROTATE_270; diff --git a/demos/spiv/spiv_config.c b/demos/spiv/spiv_config.c index 6fa95f4..73db91b 100644 --- a/demos/spiv/spiv_config.c +++ b/demos/spiv/spiv_config.c @@ -39,6 +39,7 @@ struct spiv_config config = { .zoom_strategy = ZOOM_IMAGE_DOWNSCALE, .win_strategy = ZOOM_WIN_FIXED, .full_screen = 0, + .exif_autorotate = 1, .max_win_w = 1024, .max_win_h = 768,
@@ -132,6 +133,9 @@ static int set_opt(struct cfg_opt *self, unsigned int lineno) case 't': config.timers = 1; break; + case 'r': + config.exif_autorotate = 0; + break; }
return 0; @@ -339,6 +343,14 @@ struct cfg_opt spiv_opts[] = { .help = "Orientation, one of 0, 90, 180, 270", }, {.name_space = "Gui", + .key = "DisableExifAutorotate", + .opt = 'r', + .opt_long = "disable_exif_autorotate", + .opt_has_value = 0, + .set = set_opt, + .help = "Disables automatic rotation by EXIF", + }, + {.name_space = "Gui", .key = "FullScreen", .opt = 'f', .opt_long = "full-screen", diff --git a/demos/spiv/spiv_config.h b/demos/spiv/spiv_config.h index 144ec6e..e8c713d 100644 --- a/demos/spiv/spiv_config.h +++ b/demos/spiv/spiv_config.h @@ -30,6 +30,7 @@ enum orientation { ROTATE_90, ROTATE_180, ROTATE_270, + ROTATE_360, };
enum zoom_strategy { @@ -46,7 +47,10 @@ enum zoom_strategy {
struct spiv_config { float slideshow_delay; + /* orientation set by user */ enum orientation orientation; + /* combined orientation (user orientation + EXIF rotation) */ + enum orientation combined_orientation; int win_strategy:2; int zoom_strategy:2; /* Maximal window size */ @@ -58,6 +62,7 @@ struct spiv_config { int floyd_steinberg:1; int timers:1; int full_screen:1; + int exif_autorotate:1; char backend_init[128]; GP_PixelType emul_type;
http://repo.or.cz/w/gfxprim.git/commit/d63cd2b2a46aacac0683b804d887a571a3a1a...
commit d63cd2b2a46aacac0683b804d887a571a3a1a1a7 Author: Cyril Hrubis metan@ucw.cz Date: Sat Feb 7 22:02:37 2015 +0100
DataStorage: Implement GP_DataStorageGetByPath()
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt index 79ada50..5f8d749 100644 --- a/build/syms/Loaders_symbols.txt +++ b/build/syms/Loaders_symbols.txt @@ -154,6 +154,7 @@ GP_DataStorageClear GP_DataStorageRoot GP_DataDictFirst GP_DataStorageGet +GP_DataStorageGetByPath GP_DataStorageAdd GP_DataStorageAddInt GP_DataStorageAddDouble diff --git a/include/loaders/GP_DataStorage.h b/include/loaders/GP_DataStorage.h index e8b3279..4ad9705 100644 --- a/include/loaders/GP_DataStorage.h +++ b/include/loaders/GP_DataStorage.h @@ -108,6 +108,17 @@ GP_DataNode *GP_DataStorageGet(GP_DataStorage *self, GP_DataNode *node, const char *id);
/* + * Returns data node by a path in the data storage. + * + * Example path: "/Exif/Orientation" + * + * The path works like filesystem path. The equivalent to working + * directory is the node pointer. + */ +GP_DataNode *GP_DataStorageGetByPath(GP_DataStorage *self, GP_DataNode *node, + const char *path); + +/* * Adds data into a dict. * * If node is NULL, data storage root is used. diff --git a/include/loaders/GP_Exif.h b/include/loaders/GP_Exif.h index f00cb69..5f42973 100644 --- a/include/loaders/GP_Exif.h +++ b/include/loaders/GP_Exif.h @@ -42,4 +42,14 @@ int GP_ReadExif(GP_IO *io, GP_DataStorage *storage); */ int GP_MatchExif(const void *buf);
+/* + * Defines position to 0,0 coordinate. + */ +enum GP_EXIF_ORIENTATION { + GP_EXIF_UPPER_LEFT = 1, + GP_EXIF_LOWER_RIGHT = 3, + GP_EXIF_UPPER_RIGHT = 6, + GP_EXIF_LOWER_LEFT = 8, +}; + #endif /* LOADERS_GP_EXIF_H */ diff --git a/libs/loaders/GP_DataStorage.c b/libs/loaders/GP_DataStorage.c index 2257699..b6e9db9 100644 --- a/libs/loaders/GP_DataStorage.c +++ b/libs/loaders/GP_DataStorage.c @@ -293,6 +293,60 @@ GP_DataNode *GP_DataStorageGet(GP_DataStorage *self, return NULL; }
+static struct GP_DataNode *lookup(GP_DataNode *node, const char *id, + const int id_len) +{ + struct GP_DataNode *i; + + if (!node) + return NULL; + + for (i = GP_DataDictFirst(node); i; i = i->next) { + if (!strncmp(i->id, id, id_len)) + return i; + } + + return NULL; +} + +static struct GP_DataNode *get_by_path(GP_DataNode *node, const char *path) +{ + unsigned int i; + + for (i = 0; path[i] && path[i] != '/'; i++); + + if (!i) + return node; + + node = lookup(node, path, i); + + GP_DEBUG(3, "Lookup has node '%s'", node->id); + + if (path[i] == '/') + path++; + + path+=i; + + return get_by_path(node, path); +} + +GP_DataNode *GP_DataStorageGetByPath(GP_DataStorage *self, GP_DataNode *node, + const char *path) +{ + GP_DEBUG(3, "Looking for '%s' in %p", path, node); + + if (path[0] == '/') { + + if (!self) + return NULL; + + node = GP_DataStorageRoot(self); + path++; + } + + return get_by_path(node, path); +} +
static void padd_printf(size_t padd, const char *id, size_t id_padd, const char *fmt, ...)
http://repo.or.cz/w/gfxprim.git/commit/fcb2c2cfccb1d7122b5d6683481ac7ed57fc5...
commit fcb2c2cfccb1d7122b5d6683481ac7ed57fc59c2 Author: Cyril Hrubis metan@ucw.cz Date: Sun Jan 25 21:28:40 2015 +0100
backends: X11: Catch UnmapNotify events.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/backends/GP_X11_Input.h b/libs/backends/GP_X11_Input.h index c4364b4..6305874 100644 --- a/libs/backends/GP_X11_Input.h +++ b/libs/backends/GP_X11_Input.h @@ -276,6 +276,9 @@ static void x11_input_event_put(struct GP_EventQueue *event_queue, case GravityNotify: GP_DEBUG(1, "GravityNotify event received"); break; + case UnmapNotify: + GP_DEBUG(1, "UnmapNotify event received"); + break; default: GP_WARN("Unhandled X11 event type %u", ev->type); }
http://repo.or.cz/w/gfxprim.git/commit/b71fd317db698aa14a847020003be950257ae...
commit b71fd317db698aa14a847020003be950257ae83d Author: Cyril Hrubis metan@ucw.cz Date: Fri Jan 16 17:20:51 2015 +0100
bogoman: Do screenshot on pressing s key.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/bogoman/Makefile b/demos/bogoman/Makefile index a448fee..c998522 100644 --- a/demos/bogoman/Makefile +++ b/demos/bogoman/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/pre.mk CSOURCES=$(shell echo *.c)
INCLUDE= -LDLIBS+=-lgfxprim-backends +LDLIBS+=-lgfxprim-backends -lgfxprim-loaders
APPS=bogoman
diff --git a/demos/bogoman/bogoman.c b/demos/bogoman/bogoman.c index a83cba3..36402c8 100644 --- a/demos/bogoman/bogoman.c +++ b/demos/bogoman/bogoman.c @@ -62,6 +62,8 @@ static struct GP_Backend *backend; static void event_loop(struct bogoman_render *render, GP_Backend *backend) { struct bogoman_map *map = render->map; + char path[128]; + static int screenshots;
while (GP_BackendEventsQueued(backend)) { GP_Event ev; @@ -90,6 +92,11 @@ static void event_loop(struct bogoman_render *render, GP_Backend *backend) case GP_KEY_DOWN: bogoman_map_player_move(map, 0, 1); break; + case GP_KEY_S: + snprintf(path, sizeof(path), + "screenshot%04i.png", screenshots++); + save_png(map, render->map_elem_size, path); + break; } bogoman_render(render, BOGOMAN_RENDER_DIRTY); break;
http://repo.or.cz/w/gfxprim.git/commit/c440a1bcd759c147b8f2b6739f41f9f94159c...
commit c440a1bcd759c147b8f2b6739f41f9f94159ce64 Author: Cyril Hrubis metan@ucw.cz Date: Fri Jan 16 16:48:19 2015 +0100
build: Add missing histogram symbol.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt index 4304919..52e078f 100644 --- a/build/syms/Filters_symbols.txt +++ b/build/syms/Filters_symbols.txt @@ -59,6 +59,7 @@ GP_FilterHLinearConvolution_Raw GP_FilterHistogram GP_HistogramAlloc GP_HistogramFree +GP_HistogramChannelByName
GP_FilterKernelPrint_Raw
http://repo.or.cz/w/gfxprim.git/commit/32b937c63052f6686b1d818744f172c8658d4...
commit 32b937c63052f6686b1d818744f172c8658d4be2 Author: Cyril Hrubis metan@ucw.cz Date: Fri Jan 16 16:44:18 2015 +0100
core: Get rid of GP_Color.
Special thanks to coccinelle and spatch for making this easy job. :)
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/build/syms/Core_symbols.txt b/build/syms/Core_symbols.txt index 902dbdb..47acec5 100644 --- a/build/syms/Core_symbols.txt +++ b/build/syms/Core_symbols.txt @@ -28,8 +28,6 @@ GP_SetDebugHandler
GP_PrintAbortInfo
-GP_ColorToPixel -GP_ColorLoadPixels GP_RGBA8888ToPixel GP_PixelRGBMatch GP_PixelTypeByName @@ -63,9 +61,6 @@ GP_PutPixel GP_GetPixel GP_PixelRGBLookup GP_PixelToRGB888 -GP_ColorNameToPixel -GP_ColorNameToColor -GP_ColorToColorName GP_PixelToRGBA8888
GP_Fill diff --git a/demos/c_simple/SDL_glue.c b/demos/c_simple/SDL_glue.c index a613159..8e9e216 100644 --- a/demos/c_simple/SDL_glue.c +++ b/demos/c_simple/SDL_glue.c @@ -102,8 +102,8 @@ int main(void)
GP_ContextFromSDLSurface(&context, display);
- black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &context); - darkgray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, &context); + darkgray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, &context);
redraw_screen(); SDL_Flip(display); diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c index 651ffff..5e87ff1 100644 --- a/demos/c_simple/backend_example.c +++ b/demos/c_simple/backend_example.c @@ -34,8 +34,8 @@ static void redraw(GP_Backend *self) GP_Context *context = self->context; GP_Pixel white_pixel, black_pixel;
- black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); - white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); + white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context);
GP_Fill(context, black_pixel); GP_Line(context, 0, 0, context->w - 1, context->h - 1, white_pixel); diff --git a/demos/c_simple/backend_timers_example.c b/demos/c_simple/backend_timers_example.c index 8d860e5..7b7aae2 100644 --- a/demos/c_simple/backend_timers_example.c +++ b/demos/c_simple/backend_timers_example.c @@ -32,7 +32,7 @@ static void redraw(GP_Backend *self) { GP_Context *context = self->context; - GP_Pixel black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); + GP_Pixel black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context);
GP_Fill(context, black_pixel);
diff --git a/demos/c_simple/blittest.c b/demos/c_simple/blittest.c index c6cd275..ecdb39a 100644 --- a/demos/c_simple/blittest.c +++ b/demos/c_simple/blittest.c @@ -174,8 +174,8 @@ int main(void) win->context->pixel_type); change_bitmap();
- black = GP_ColorToContextPixel(GP_COL_BLACK, win->context); - white = GP_ColorToContextPixel(GP_COL_WHITE, win->context); + black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context); + white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context);
GP_Fill(win->context, black); GP_BackendFlip(win); diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c index 2d06dae..972514b 100644 --- a/demos/c_simple/fileview.c +++ b/demos/c_simple/fileview.c @@ -263,12 +263,12 @@ int main(int argc, char *argv[])
win = backend->context;
- white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, win); - gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, win); - dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, win); - black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, win); - red_pixel = GP_ColorToContextPixel(GP_COL_RED, win); - blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, win); + white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, win); + gray_pixel = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, win); + dark_gray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, win); + red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, win); + blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, win);
redraw_screen(); GP_BackendFlip(backend); diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c index 4e33020..9a3aff1 100644 --- a/demos/c_simple/fonttest.c +++ b/demos/c_simple/fonttest.c @@ -277,12 +277,12 @@ int main(int argc, char *argv[]) return 1; }
- white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, win->context); - gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, win->context); - dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, win->context); - black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, win->context); - red_pixel = GP_ColorToContextPixel(GP_COL_RED, win->context); - blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, win->context); + white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); + gray_pixel = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, win->context); + dark_gray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win->context); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context); + red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, win->context); + blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, win->context);
redraw_screen(); GP_BackendFlip(win); diff --git a/demos/c_simple/input_example.c b/demos/c_simple/input_example.c index 3b94ce3..3a294d2 100644 --- a/demos/c_simple/input_example.c +++ b/demos/c_simple/input_example.c @@ -150,10 +150,10 @@ int main(int argc, char *argv[])
win = backend->context;
- red = GP_ColorToContextPixel(GP_COL_RED, win); - green = GP_ColorToContextPixel(GP_COL_GREEN, win); - white = GP_ColorToContextPixel(GP_COL_WHITE, win); - black = GP_ColorToContextPixel(GP_COL_BLACK, win); + red = GP_RGBToContextPixel(0xff, 0x00, 0x00, win); + green = GP_RGBToContextPixel(0x00, 0xff, 0x00, win); + white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win); + black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win);
GP_Fill(win, black); GP_BackendFlip(backend); diff --git a/demos/c_simple/koch.c b/demos/c_simple/koch.c index 335815d..5bb1538 100644 --- a/demos/c_simple/koch.c +++ b/demos/c_simple/koch.c @@ -138,10 +138,10 @@ int main(void)
context = backend->context;
- black = GP_ColorToContextPixel(GP_COL_BLACK, context); - blue = GP_ColorToContextPixel(GP_COL_BLUE, context); - gray = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, context); - red = GP_ColorToContextPixel(GP_COL_RED, context); + black = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); + blue = GP_RGBToContextPixel(0x00, 0x00, 0xff, context); + gray = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, context); + red = GP_RGBToContextPixel(0xff, 0x00, 0x00, context);
iter = 0; draw(context->w/2, context->h/2, l, iter); diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c index 1df6e6e..19a0244 100644 --- a/demos/c_simple/linetest.c +++ b/demos/c_simple/linetest.c @@ -135,8 +135,8 @@ int main(int argc, char *argv[]) return 1; }
- white = GP_ColorToContextPixel(GP_COL_WHITE, win->context); - black = GP_ColorToContextPixel(GP_COL_BLACK, win->context); + white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); + black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context);
redraw_screen();
diff --git a/demos/c_simple/randomshapetest.c b/demos/c_simple/randomshapetest.c index f3dbaa1..e5f4e5d 100644 --- a/demos/c_simple/randomshapetest.c +++ b/demos/c_simple/randomshapetest.c @@ -268,8 +268,8 @@ int main(void) return 1; }
- white = GP_ColorToContextPixel(GP_COL_WHITE, win->context); - black = GP_ColorToContextPixel(GP_COL_BLACK, win->context); + white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); + black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context);
for (;;) { GP_BackendPoll(win); diff --git a/demos/c_simple/shapetest.c b/demos/c_simple/shapetest.c index db32938..b114fd8 100644 --- a/demos/c_simple/shapetest.c +++ b/demos/c_simple/shapetest.c @@ -505,13 +505,13 @@ int main(int argc, char *argv[]) center_y = win->h / 2;
/* Load colors compatible with the display */ - black = GP_ColorToContextPixel(GP_COL_BLACK, win); - white = GP_ColorToContextPixel(GP_COL_WHITE, win); - yellow = GP_ColorToContextPixel(GP_COL_YELLOW, win); - green = GP_ColorToContextPixel(GP_COL_GREEN, win); - red = GP_ColorToContextPixel(GP_COL_RED, win); - gray = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, win); - darkgray = GP_ColorToContextPixel(GP_COL_GRAY_DARK, win); + black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win); + white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win); + yellow = GP_RGBToContextPixel(0xff, 0xff, 0x00, win); + green = GP_RGBToContextPixel(0x00, 0xff, 0x00, win); + red = GP_RGBToContextPixel(0xff, 0x00, 0x00, win); + gray = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, win); + darkgray = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win);
print_instructions(); redraw_screen(); diff --git a/demos/c_simple/textaligntest.c b/demos/c_simple/textaligntest.c index 70b2fd2..5e2fbd6 100644 --- a/demos/c_simple/textaligntest.c +++ b/demos/c_simple/textaligntest.c @@ -181,13 +181,13 @@ int main(int argc, char *argv[]) return 1; }
- black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, win->context); - red_pixel = GP_ColorToContextPixel(GP_COL_RED, win->context); - blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, win->context); - green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, win->context); - yellow_pixel = GP_ColorToContextPixel(GP_COL_YELLOW, win->context); - white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, win->context); - darkgray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, win->context); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context); + red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, win->context); + blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, win->context); + green_pixel = GP_RGBToContextPixel(0x00, 0xff, 0x00, win->context); + yellow_pixel = GP_RGBToContextPixel(0xff, 0xff, 0x00, win->context); + white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); + darkgray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win->context);
redraw_screen(); GP_BackendFlip(win); diff --git a/demos/c_simple/virtual_backend_example.c b/demos/c_simple/virtual_backend_example.c index 925a3d6..5ef5a8e 100644 --- a/demos/c_simple/virtual_backend_example.c +++ b/demos/c_simple/virtual_backend_example.c @@ -93,11 +93,11 @@ int main(int argc, char *argv[]) context = backend->context;
/* Now draw some testing patters */ - black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); - white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); - red_pixel = GP_ColorToContextPixel(GP_COL_RED, context); - blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, context); - green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, context); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); + white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); + red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, context); + blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, context); + green_pixel = GP_RGBToContextPixel(0x00, 0xff, 0x00, context);
GP_Fill(context, white_pixel);
diff --git a/demos/c_simple/x11_windows.c b/demos/c_simple/x11_windows.c index fa52cc2..1c5b2d0 100644 --- a/demos/c_simple/x11_windows.c +++ b/demos/c_simple/x11_windows.c @@ -33,8 +33,8 @@ static void redraw(struct GP_Context *context) { GP_Pixel white_pixel, black_pixel;
- black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); - white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); + white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context);
GP_Fill(context, black_pixel); GP_Line(context, 0, 0, context->w - 1, context->h - 1, white_pixel); diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c index 2b902a0..46fafe2 100644 --- a/demos/particle/particle_demo.c +++ b/demos/particle/particle_demo.c @@ -90,8 +90,8 @@ int main(int argc, char *argv[])
context = backend->context;
- black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); - white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); + white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context);
GP_Fill(context, black_pixel); GP_BackendFlip(backend); diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 40a5687..75af202 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -818,8 +818,8 @@ int main(int argc, char *argv[])
context = backend->context;
- black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); - white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); + black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); + white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); gray_pixel = GP_RGBToContextPixel(0x33, 0x33, 0x33, context);
GP_Fill(context, black_pixel); diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c index ef1f0c5..2d7eac9 100644 --- a/demos/spiv/spiv_help.c +++ b/demos/spiv/spiv_help.c @@ -235,8 +235,8 @@ static int last_line; static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff) { GP_Context *c = backend->context; - GP_Pixel black = GP_ColorToContextPixel(GP_COL_BLACK, c); - GP_Pixel white = GP_ColorToContextPixel(GP_COL_WHITE, c); + GP_Pixel black = GP_RGBToContextPixel(0x00, 0x00, 0x00, c); + GP_Pixel white = GP_RGBToContextPixel(0xff, 0xff, 0xff, c); int i;
int spacing = GP_TextHeight(config.style)/10 + 2; diff --git a/demos/ttf2img/ttf2img.c b/demos/ttf2img/ttf2img.c index 9bc4558..deaa37a 100644 --- a/demos/ttf2img/ttf2img.c +++ b/demos/ttf2img/ttf2img.c @@ -76,8 +76,8 @@ int main(int argc, char *argv[])
GP_Context *context = GP_ContextAlloc(img_w, img_h, GP_PIXEL_RGB888);
- GP_Pixel black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); - GP_Pixel white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); + GP_Pixel black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); + GP_Pixel white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context);
GP_Fill(context, white_pixel);
diff --git a/doc/basic_types.txt b/doc/basic_types.txt index 11ff214..3b6c6fd 100644 --- a/doc/basic_types.txt +++ b/doc/basic_types.txt @@ -17,75 +17,3 @@ values. The default typedef for 'GP_Pixel' is set to 32 bit integer, which may be changed at compile time to support colors with more than 10 bits per channel. The 'GP_Pixel' is thus used as opaque value big enough to hold any supported pixel value. - -[[Color]] -Color -~~~~~ - -The 'GP_Color' enumeration holds symbolic constants for basic colors. - -A 'GP_Color' can be converted into a 'GP_Pixel' for a given 'GP_PixelType'. -Symbolic values can also be converted to/from strings (color name in English). - -The 'GP_Color' enum is defined as follows: - -[source,c] --------------------------------------------------------------------------------- -typedef enum GP_Color { - GP_COL_INVALID = -1, - - /* full-intensity RGB and CMYK */ - GP_COL_BLACK, - GP_COL_RED, - GP_COL_GREEN, - GP_COL_BLUE, - GP_COL_YELLOW, - GP_COL_CYAN, - GP_COL_MAGENTA, - - /* various common mixes */ - GP_COL_BROWN, - GP_COL_ORANGE, - GP_COL_GRAY_DARK, /* exactly half RGB values of white */ - GP_COL_GRAY_LIGHT, - GP_COL_PURPLE, - - GP_COL_WHITE, /* full-intensity white */ - GP_COL_MAX, -} GP_Color; --------------------------------------------------------------------------------- - -[source,c] --------------------------------------------------------------------------------- -#include <core/GP_Color.h> -/* or */ -#include <GP.h> - -GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type); -GP_Pixel GP_ColorToContextPixel(GP_Color color, GP_Context *context); - -GP_Color GP_ColorNameToColor(const char *color_name); -const char *GP_ColorToColorName(GP_Color color); - -bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type, - GP_Pixel *pixel); -bool GP_ColorNameToContextPixel(const char *color_name, GP_Context *context, - GP_Pixel *pixel); --------------------------------------------------------------------------------- - -Functions for conversion between colors, pixels and color names. The last two -returns true if color with such name was found. - -[source,c] --------------------------------------------------------------------------------- -#include <core/GP_Color.h> -/* or */ -#include <GP.h> - -void GP_ColorLoadPixels(GP_Pixel pixels[], GP_PixelType pixel_type); -void GP_ColorLoadContextPixels(GP_Pixel pixels[], GP_Context *context); --------------------------------------------------------------------------------- - -Loads array of 'GP_Pixel' of size 'GP_COL_MAX', the array is then used with -the GP_Color enum as 'pixels[GP_COL_BLACK]'. - diff --git a/doc/convert.txt b/doc/convert.txt index 9191805..f11f932 100644 --- a/doc/convert.txt +++ b/doc/convert.txt @@ -3,8 +3,6 @@ Pixel Conversions
This page describes RGB tripplet to pixels conversions.
-See also link:basic_types.html#Color[colors]. - [source,c] ------------------------------------------------------------------------------- #include <GP.h> diff --git a/doc/core_python.txt b/doc/core_python.txt index 487b903..108c859 100644 --- a/doc/core_python.txt +++ b/doc/core_python.txt @@ -101,15 +101,13 @@ Blit is clipped.
TIP: See link:example_py_showimage.html[example Blit usage].
-[[Colors_and_Pixels]] -Colors and Pixels -~~~~~~~~~~~~~~~~~ +[[Pixels]] +Pixels +~~~~~~
Pixel in GFXprim is a number large enough to store a pixel value. Pixel is passed as a parameter to all drawing functions.
-Color is a more abstract representation for example RGB triplet. - There are several functions to create a pixel value for a particular pixel type from color.
@@ -128,7 +126,6 @@ import gfxprim.core as core These functions creates a pixel suitable for drawing into a bitmap with particular pixel type.
- [source,python] ------------------------------------------------------------------------------- import gfxprim.core as core diff --git a/include/core/GP_Color.h b/include/core/GP_Color.h deleted file mode 100644 index de87e6a..0000000 --- a/include/core/GP_Color.h +++ /dev/null @@ -1,124 +0,0 @@ -/***************************************************************************** - * 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-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - - /* - - Color is enumeration of color names which may be converted into pixel values - in desired pixel format. - - */ - -#ifndef GP_COLOR_H -#define GP_COLOR_H - -#include "GP_Context.h" -#include "GP_Pixel.h" - -/* - * Enumeration of color constants. - */ -typedef enum GP_Color { - GP_COL_INVALID = -1, - GP_COL_BLACK, - GP_COL_RED, - GP_COL_GREEN, - GP_COL_BLUE, - GP_COL_YELLOW, - GP_COL_CYAN, - GP_COL_MAGENTA, - GP_COL_BROWN, - GP_COL_ORANGE, - GP_COL_GRAY_DARK, - GP_COL_GRAY_LIGHT, - GP_COL_PURPLE, - GP_COL_WHITE, - GP_COL_MAX, -} GP_Color; - -/* - * Converts GP_Color to GP_Pixel. - */ -GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type); - -/* - * Converts GP_Color to GP_Pixel. - */ -static inline GP_Pixel GP_ColorToContextPixel(GP_Color color, - GP_Context *context) -{ - return GP_ColorToPixel(color, context->pixel_type); -} - -/* - * Converts Color name (eg. string) to GP_Color. - */ -GP_Color GP_ColorNameToColor(const char *color_name); - -/* - * Converts GP_Color to color name. - * - * If color is not valid NULL is returned. - */ -const char *GP_ColorToColorName(GP_Color color); - -/* - * Converts Color name to Pixel. - * - * Returns true if conversion was successful false otherwise. - */ -bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type, - GP_Pixel *pixel); - -/* - * Converts Color name to Pixel. - * - * Returns true if conversion was successful false otherwise. - */ -static inline bool GP_ColorNameToContextPixel(const char *color_name, - GP_Context *context, - GP_Pixel *pixel) -{ - return GP_ColorNameToPixel(color_name, context->pixel_type, pixel); -} - -/* - * Loads all colors into array of GP_Pixel of size GP_COL_MAX. - * - * The colors are then used as pixels[GP_COL_XXX]; - */ -void GP_ColorLoadPixels(GP_Pixel pixels[], GP_PixelType pixel_type); - -/* - * Loads all colors into array of GP_Pixel of size GP_COL_MAX. - * - * The colors are then used as pixels[GP_COL_XXX]; - */ -static inline void GP_ColorLoadContextPixels(GP_Pixel pixels[], - GP_Context *context) -{ - GP_ColorLoadPixels(pixels, context->pixel_type); -} - -#endif /* GP_COLOR_H */ diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h index b9f1b6a..bef6834 100644 --- a/include/core/GP_Core.h +++ b/include/core/GP_Core.h @@ -65,9 +65,6 @@ /* Debug and debug level */ #include "core/GP_Debug.h"
-/* Color */ -#include "core/GP_Color.h" - /* Progress callback */ #include "core/GP_ProgressCallback.h"
diff --git a/libs/core/GP_Color.c b/libs/core/GP_Color.c deleted file mode 100644 index 2c42d4a..0000000 --- a/libs/core/GP_Color.c +++ /dev/null @@ -1,135 +0,0 @@ -/***************************************************************************** - * 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-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include <stdint.h> -#include <string.h> - -#include "GP_Convert.h" - -#include "GP_Color.h" - - -static char *color_names[] = { - "Black", - "Red", - "Green", - "Blue", - "Yellow", - "Cyan", - "Magenta", - "Brown", - "Orange", - "DarkGray", - "LightGray", - "Purple", - "White" -}; - -static uint8_t rgb888_colors[][3] = { - {0x00, 0x00, 0x00}, /* Black */ - {0xff, 0x00, 0x00}, /* Red */ - {0x00, 0xff, 0x00}, /* Green */ - {0x00, 0x00, 0xff}, /* Blue */ - {0xff, 0xff, 0x00}, /* Yellow */ - {0x00, 0xff, 0xff}, /* Cyan */ - {0xff, 0x00, 0xff}, /* Magenta */ - {0xa5, 0x2a, 0x2a}, /* Brown */ - {0xff, 0xa5, 0x00}, /* Orange */ - {0x7f, 0x7f, 0x7f}, /* DarkGray */ - {0xbe, 0xbe, 0xbe}, /* LightGray */ - {0xa0, 0x20, 0xf0}, /* Purple */ - {0xff, 0xff, 0xff}, /* White */ -}; - -/* 3-2-3 RGB palette */ -static uint8_t p8_colors[] = { - 0x00, /* Black */ - 0xe0, /* Red */ - 0x1c, /* Green */ - 0x03, /* Blue */ - 0xfc, /* Yellow */ - 0x1f, /* Cyan */ - 0xe7, /* Magenta */ - 0x88, /* Brown */ - 0xf0, /* Orange */ - 0x49, /* DarkGray */ - 0x92, /* LightGray */ - 0x8a, /* Purple */ - 0xff, /* White */ -}; - -GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type) -{ - GP_ASSERT(color < GP_COL_MAX); - GP_ASSERT(color >= 0); - - if (pixel_type == GP_PIXEL_P8) - return p8_colors[color]; - - return GP_RGBToPixel(rgb888_colors[color][0], - rgb888_colors[color][1], - rgb888_colors[color][2], - pixel_type); -} - -GP_Color GP_ColorNameToColor(const char *color_name) -{ - unsigned int i; - - for (i = 0; i < GP_COL_MAX; i++) - if (!strcasecmp(color_name, color_names[i])) - return i; - - return -1; -} - -const char *GP_ColorToColorName(GP_Color color) -{ - if (color < 0 || color >= GP_COL_MAX) - return NULL; - - return color_names[color]; -} - -bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type, - GP_Pixel *pixel) -{ - GP_Color color = GP_ColorNameToColor(color_name); - - if (color == GP_COL_INVALID) - return false; - - *pixel = GP_ColorToPixel(color, pixel_type); - - return true; -} - -void GP_ColorLoadPixels(GP_Pixel pixels[], GP_PixelType pixel_type) -{ - unsigned int i; - - for (i = 0; i < GP_COL_MAX; i++) - pixels[i] = GP_ColorToPixel(i, pixel_type); -} diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index ff0c062..b0aff17 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -28,12 +28,8 @@ %include "GP_Debug.h"
/* - * Color and pixel types + * Pixel types */ - -ERROR_ON_NULL(GP_ColorToColorName); - -%include "GP_Color.h" %include "GP_Pixel.h" %include "GP_Pixel.gen.h" /* Includes enum GP_PixelType definition */ %include "GP_Convert.h"
http://repo.or.cz/w/gfxprim.git/commit/e42857ad289d9333411766b2df90cffea906c...
commit e42857ad289d9333411766b2df90cffea906cf11 Author: Cyril Hrubis metan@ucw.cz Date: Fri Jan 16 16:14:38 2015 +0100
spiv: Add support for metadata viewer.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/spiv/image_cache.c b/demos/spiv/image_cache.c index c030405..5f270a8 100644 --- a/demos/spiv/image_cache.c +++ b/demos/spiv/image_cache.c @@ -27,6 +27,7 @@
struct image { GP_Context *ctx; + GP_DataStorage *meta_data;
struct image *prev; struct image *next; @@ -72,15 +73,23 @@ size_t image_cache_get_ram_size(void) /* * Reports correct image record size. */ -static size_t image_size2(GP_Context *ctx, const char *path) +static size_t image_size2(GP_Context *ctx, GP_DataStorage *meta_data, + const char *path) { - return ctx->bytes_per_row * ctx->h + sizeof(GP_Context) + + size_t meta_data_size = 0; + size_t context_size = ctx->bytes_per_row * ctx->h + sizeof(GP_Context); + + //TODO! 4096 is a size of single block, data storage may have more blocks + if (meta_data) + meta_data_size = 4096; + + return meta_data_size + context_size + sizeof(struct image) + strlen(path) + 1; }
static size_t image_size(struct image *img) { - return image_size2(img->ctx, img->path); + return image_size2(img->ctx, NULL, img->path); }
struct image_cache *image_cache_create(unsigned int max_size_kbytes) @@ -127,6 +136,7 @@ static void remove_img_free(struct image_cache *self,
remove_img(self, img, size); GP_ContextFree(img->ctx); + GP_DataStorageDestroy(img->meta_data); free(img); }
@@ -149,13 +159,13 @@ static void add_img(struct image_cache *self, struct image *img, size_t size) self->end = img; }
-GP_Context *image_cache_get(struct image_cache *self, int elevate, - const char *key) +int image_cache_get(struct image_cache *self, GP_Context **img, + GP_DataStorage **meta_data, int elevate, const char *key) { struct image *i;
if (self == NULL) - return NULL; + return 1;
GP_DEBUG(2, "Looking for image '%s'", key);
@@ -164,7 +174,7 @@ GP_Context *image_cache_get(struct image_cache *self, int elevate, break;
if (i == NULL) - return NULL; + return 1;
/* Push the image to the root of the list */ if (elevate) { @@ -178,7 +188,13 @@ GP_Context *image_cache_get(struct image_cache *self, int elevate, i->elevated++; }
- return i->ctx; + if (img) + *img = i->ctx; + + if (meta_data) + *meta_data = i->meta_data; + + return 0; }
GP_Context *image_cache_get2(struct image_cache *self, int elevate, @@ -268,14 +284,14 @@ static int assert_size(struct image_cache *self, size_t size) }
int image_cache_put(struct image_cache *self, GP_Context *ctx, - const char *key) + GP_DataStorage *meta_data, const char *key) { size_t size;
if (self == NULL) return 1;
- size = image_size2(ctx, key); + size = image_size2(ctx, meta_data, key);
/* * We try to create room for the image. If this fails we add the image @@ -292,6 +308,7 @@ int image_cache_put(struct image_cache *self, GP_Context *ctx, }
img->ctx = ctx; + img->meta_data = meta_data; img->elevated = 0; strcpy(img->path, key);
@@ -303,7 +320,7 @@ int image_cache_put(struct image_cache *self, GP_Context *ctx, }
int image_cache_put2(struct image_cache *self, GP_Context *ctx, - const char *fmt, ...) + GP_DataStorage *meta_data, const char *fmt, ...) { size_t size, len; va_list va; @@ -316,7 +333,7 @@ int image_cache_put2(struct image_cache *self, GP_Context *ctx, va_end(va);
//TODO: FIX THIS - size = image_size2(ctx, "") + len + 1; + size = image_size2(ctx, meta_data, "") + len + 1;
/* * We try to create room for the image. If this fails we add the image @@ -333,6 +350,7 @@ int image_cache_put2(struct image_cache *self, GP_Context *ctx, }
img->ctx = ctx; + img->meta_data = meta_data; img->elevated = 0;
va_start(va, fmt); diff --git a/demos/spiv/image_cache.h b/demos/spiv/image_cache.h index b08ed48..f2ea1fa 100644 --- a/demos/spiv/image_cache.h +++ b/demos/spiv/image_cache.h @@ -47,8 +47,9 @@ struct image_cache *image_cache_create(unsigned int max_size_kbytes); * If elevate set and image is found, the image is elevated to the top so * it has lesser chance of being freed. */ -GP_Context *image_cache_get(struct image_cache *self, int elevate, - const char *key); +int image_cache_get(struct image_cache *self, GP_Context **img, + GP_DataStorage **meta_data, int elevate, + const char *key);
GP_Context *image_cache_get2(struct image_cache *self, int elevate, const char *fmt, ...) @@ -57,11 +58,11 @@ GP_Context *image_cache_get2(struct image_cache *self, int elevate, * Puts an image into a cache. */ int image_cache_put(struct image_cache *self, GP_Context *img, - const char *key); + GP_DataStorage *meta_data, const char *key);
int image_cache_put2(struct image_cache *self, GP_Context *img, - const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); + GP_DataStorage *meta_data, const char *fmt, ...) + __attribute__ ((format (printf, 4, 5)));
/* * Drop all image in cache. diff --git a/demos/spiv/image_loader.c b/demos/spiv/image_loader.c index d033529..c7e0f9b 100644 --- a/demos/spiv/image_loader.c +++ b/demos/spiv/image_loader.c @@ -35,6 +35,7 @@ static struct image_cache *img_cache; static struct image_list *img_list; static GP_Context *cur_img; +static GP_DataStorage *cur_meta_data; static GP_Container *cur_cont;
int image_loader_init(const char *args[], unsigned int cache_max_bytes) @@ -61,30 +62,31 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate) struct cpu_timer timer; const char *path; GP_Context *img; - int err; + int err, ret;
if (cur_img) return cur_img;
if (cur_cont) { cpu_timer_start(&timer, "Loading"); - cur_img = GP_ContainerLoad(cur_cont, callback); + cur_meta_data = GP_DataStorageCreate(); + GP_ContainerLoadEx(cur_cont, &cur_img, cur_meta_data, callback); cpu_timer_stop(&timer); return cur_img; }
path = image_list_img_path(img_list);
- cur_img = image_cache_get(img_cache, elevate, path); - - if (cur_img) + if (!image_cache_get(img_cache, &cur_img, &cur_meta_data, elevate, path)) return cur_img;
cpu_timer_start(&timer, "Loading");
- img = GP_LoadImage(path, callback); + cur_meta_data = GP_DataStorageCreate();
- if (!img) { + ret = GP_LoadImageEx(path, &img, cur_meta_data, callback); + + if (ret) { err = errno;
/* @@ -95,7 +97,7 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate) cur_cont = GP_OpenZip(path);
if (cur_cont) { - img = GP_ContainerLoad(cur_cont, callback); + GP_ContainerLoadEx(cur_cont, &img, cur_meta_data, callback);
if (img) { cur_img = img; @@ -111,13 +113,18 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate) return NULL; }
- image_cache_put(img_cache, img, path); + image_cache_put(img_cache, img, cur_meta_data, path);
cpu_timer_stop(&timer);
return img; }
+GP_DataStorage *image_loader_get_meta_data(void) +{ + return cur_meta_data; +} + const char *image_loader_img_path(void) { //TODO: Make this more elegant @@ -146,10 +153,13 @@ static void drop_cur_img(void) /* * Currently loaded image is too big to be cached -> free it. */ - if (!image_cache_get(img_cache, 0, path)) + if (image_cache_get(img_cache, NULL, NULL, 0, path)) { GP_ContextFree(cur_img); + GP_DataStorageDestroy(cur_meta_data); + }
cur_img = NULL; + cur_meta_data = NULL; }
void image_loader_seek(enum img_seek_offset offset, int whence) diff --git a/demos/spiv/image_loader.h b/demos/spiv/image_loader.h index 46b65fa..9992bca 100644 --- a/demos/spiv/image_loader.h +++ b/demos/spiv/image_loader.h @@ -49,6 +49,11 @@ int image_loader_init(const char *args[], unsigned int cache_max_bytes); GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate);
/* + * Retruns current image meta data or NULL there are none. + */ +GP_DataStorage *image_loader_get_meta_data(void); + +/* * Returns path to current image. */ const char *image_loader_img_path(void); diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 3cf212c..40a5687 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -213,6 +213,39 @@ static void info_printf(GP_Context *ctx, GP_Coord x, GP_Coord y, va_end(va); }
+static unsigned int print_meta_data(GP_DataNode *node, GP_Context *context, + unsigned int th, unsigned int y, int level) +{ + GP_DataNode *i; + unsigned int x; + + for (i = GP_DataDictFirst(node); i; i = i->next) { + y += th; + x = th * level + 10; + switch (i->type) { + case GP_DATA_INT: + info_printf(context, x, y, "%s : %li", i->id, i->value.i); + break; + case GP_DATA_DOUBLE: + info_printf(context, x, y, "%s : %lf", i->id, i->value.d); + break; + case GP_DATA_STRING: + info_printf(context, x, y, "%s : %s", i->id, i->value.str); + break; + case GP_DATA_RATIONAL: + info_printf(context, x, y, "%s : %li/%li", + i->id, i->value.rat.num, i->value.rat.den); + break; + case GP_DATA_DICT: + info_printf(context, x, y, "%s", i->id); + y = print_meta_data(i, context, th, y, level+1); + break; + } + } + + return y; +} + static void show_info(struct loader_params *params, GP_Context *img, GP_Context *orig_img) { @@ -248,14 +281,25 @@ static void show_info(struct loader_params *params, GP_Context *img, info_printf(context, 10, y, "%u of %u", pos, count); y += th + 2;
- if (!image_loader_is_in_dir()) + if (image_loader_is_in_dir()) { + unsigned int dir_count = image_loader_dir_count(); + unsigned int dir_pos = image_loader_dir_pos() + 1; + + info_printf(context, 10, y, + "%u of %u in directory", dir_pos, dir_count); + } + + GP_DataStorage *meta_data = image_loader_get_meta_data(); + + if (!meta_data) return;
- unsigned int dir_count = image_loader_dir_count(); - unsigned int dir_pos = image_loader_dir_pos() + 1; + GP_DataNode *node = GP_DataStorageRoot(meta_data); + + if (node->type != GP_DATA_DICT) + return;
- info_printf(context, 10, y, - "%u of %u in directory", dir_pos, dir_count); + print_meta_data(node, context, th + 2, y + th, 0); }
static void update_display(struct loader_params *params, GP_Context *img, @@ -414,7 +458,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size if (img == NULL) return NULL;
- image_cache_put2(params->img_resized_cache, img, "%s %ux%u r%i l%i", + image_cache_put2(params->img_resized_cache, img, NULL, "%s %ux%u r%i l%i", img_path, w, h, params->resampling_method, params->use_low_pass);
-----------------------------------------------------------------------
Summary of changes: build/syms/Core_symbols.txt | 5 - build/syms/Filters_symbols.txt | 1 + build/syms/Loaders_symbols.txt | 1 + demos/bogoman/Makefile | 2 +- demos/bogoman/bogoman.c | 7 ++ demos/c_simple/SDL_glue.c | 4 +- demos/c_simple/backend_example.c | 4 +- demos/c_simple/backend_timers_example.c | 2 +- demos/c_simple/blittest.c | 4 +- demos/c_simple/fileview.c | 12 ++-- demos/c_simple/fonttest.c | 12 ++-- demos/c_simple/input_example.c | 8 +- demos/c_simple/koch.c | 8 +- demos/c_simple/linetest.c | 4 +- demos/c_simple/randomshapetest.c | 4 +- demos/c_simple/shapetest.c | 14 ++-- demos/c_simple/textaligntest.c | 14 ++-- demos/c_simple/virtual_backend_example.c | 10 +- demos/c_simple/x11_windows.c | 4 +- demos/particle/particle_demo.c | 4 +- demos/spiv/image_cache.c | 42 +++++++--- demos/spiv/image_cache.h | 11 ++- demos/spiv/image_loader.c | 30 +++++-- demos/spiv/image_loader.h | 5 + demos/spiv/spiv.c | 111 +++++++++++++++++++++---- demos/spiv/spiv_config.c | 12 +++ demos/spiv/spiv_config.h | 5 + demos/spiv/spiv_help.c | 4 +- demos/ttf2img/ttf2img.c | 4 +- doc/basic_types.txt | 72 ---------------- doc/convert.txt | 2 - doc/core_python.txt | 9 +-- include/core/GP_Color.h | 124 --------------------------- include/core/GP_Core.h | 3 - include/loaders/GP_DataStorage.h | 11 +++ include/loaders/GP_Exif.h | 10 ++ libs/backends/GP_X11_Input.h | 3 + libs/core/GP_Color.c | 135 ------------------------------ libs/loaders/GP_DataStorage.c | 54 ++++++++++++ pylib/gfxprim/core/core.i | 6 +- 40 files changed, 324 insertions(+), 453 deletions(-) delete mode 100644 include/core/GP_Color.h delete mode 100644 libs/core/GP_Color.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.