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 cac343079cd56a28eac9e54ca3ab4aeee3fba683 (commit) from 5e645909989e30e94ffe9eacf2177f441d44c2d6 (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/cac343079cd56a28eac9e54ca3ab4aeee3fba...
commit cac343079cd56a28eac9e54ca3ab4aeee3fba683 Author: Cyril Hrubis metan@ucw.cz Date: Sat Nov 26 01:04:42 2011 +0100
fbshow: Some more work on fbshow.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c index 082c888..27af5e3 100644 --- a/demos/fbshow/fbshow.c +++ b/demos/fbshow/fbshow.c @@ -43,18 +43,43 @@ static GP_Framebuffer *fb = NULL; /* image loader thread */ static int abort_flag = 0; static int rotate = 0; +static int show_progress = 0;
static int image_loader_callback(GP_ProgressCallback *self) { + static GP_Size size = 0; + if (abort_flag) return 1; - + + if (!show_progress) + return 0; + + char buf[100]; + + snprintf(buf, sizeof(buf), "%s ... %-3.1f%%", + (const char*)self->priv, self->percentage); + + GP_Context *c = &fb->context; + + int align = GP_ALIGN_CENTER|GP_VALIGN_ABOVE; + + GP_TextClear(c, NULL, c->w/2, c->h - 4, align, + black_pixel, GP_MAX(size, GP_TextWidth(NULL, buf))); + + GP_Text(c, NULL, c->w/2, c->h - 4, align, + white_pixel, black_pixel, buf); + + size = GP_TextWidth(NULL, buf); + return 0; }
struct loader_params { const char *img_path; - int clear; + int show_progress; + int show_progress_once; + int show_info; };
static float calc_img_size(uint32_t img_w, uint32_t img_h, @@ -66,31 +91,40 @@ static float calc_img_size(uint32_t img_w, uint32_t img_h, return GP_MIN(w_rat, h_rat); }
+static const char *img_name(const char *img_path) +{ + int i, len = strlen(img_path); + + for (i = len - 1; i > 0; i--) { + if (img_path[i] == '/') + return &img_path[i+1]; + } + + return NULL; +} + static void *image_loader(void *ptr) { struct loader_params *params = ptr; GP_ProgressCallback callback = {.callback = image_loader_callback};
- fprintf(stderr, "Loading '%s'n", params->img_path); + show_progress = params->show_progress || params->show_progress_once; + params->show_progress_once = 0;
- if (params->clear) { - char buf[100]; - snprintf(buf, sizeof(buf), "Loading '%s'", params->img_path); - GP_Fill(&fb->context, black_pixel); - //GP_BoxCenteredText(&fb->context, NULL, 0, 0, - // fb->context.w, fb->context.h, - // buf, white_pixel); - } + fprintf(stderr, "Loading '%s'n", params->img_path);
GP_Context *img = NULL;
+ callback.priv = "Loading image"; + if (GP_LoadImage(params->img_path, &img, &callback) != 0) { - // GP_BoxCenteredText(&fb->context, NULL, 0, 0, - // fb->context.w, fb->context.h, - // "Failed to load image", white_pixel); + GP_Fill(&fb->context, black_pixel); + GP_Text(&fb->context, NULL, fb->context.w/2, fb->context.h/2, + GP_ALIGN_CENTER|GP_VALIGN_CENTER, black_pixel, white_pixel, + "Failed to load image :("); return NULL; } - + GP_Size w, h;
switch (rotate) { @@ -109,6 +143,9 @@ static void *image_loader(void *ptr)
float rat = calc_img_size(img->w, img->h, w, h);
+ w = img->w; + h = img->h; + /* Workaround */ if (img->pixel_type != GP_PIXEL_RGB888) { GP_Context *tmp = GP_ContextConvert(img, NULL, GP_PIXEL_RGB888); @@ -116,11 +153,13 @@ static void *image_loader(void *ptr) img = tmp; } - GP_Context *ret;
-// if (GP_FilterGaussianBlur(img, img, 0.7, 0.7, &callback)) -// return NULL; + //callback.priv = "Blurring Image"; + //if (GP_FilterGaussianBlur(img, img, 0.25/rat, 0.25/rat, &callback) == NULL) + // return NULL; + + callback.priv = "Resampling Image"; ret = GP_FilterResize(img, NULL, GP_INTERP_CUBIC, img->w * rat, img->h * rat, &callback); GP_ContextFree(img);
@@ -131,12 +170,15 @@ static void *image_loader(void *ptr) case 0: break; case 90: + callback.priv = "Rotating image (90)"; img = GP_FilterRotate90(ret, NULL, &callback); break; case 180: + callback.priv = "Rotating image (180)"; img = GP_FilterRotate180(ret, NULL, &callback); break; case 270: + callback.priv = "Rotating image (270)"; img = GP_FilterRotate270(ret, NULL, &callback); break; } @@ -161,19 +203,38 @@ static void *image_loader(void *ptr) GP_FillRectXYWH(&fb->context, ret->w+cx, 0, cx, fb->context.h, black_pixel); GP_FillRectXYWH(&fb->context, 0, ret->h+cy, fb->context.w, cy, black_pixel);
+ if (!params->show_info) + return NULL; + + GP_Size th = GP_TextHeight(NULL); + + GP_Print(&fb->context, NULL, 11, 11, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + black_pixel, white_pixel, "%ux%u", w, h); + + GP_Print(&fb->context, NULL, 10, 10, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + white_pixel, black_pixel, "%ux%u", w, h); + + GP_Print(&fb->context, NULL, 11, 13 + th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + black_pixel, white_pixel, "1:%3.3f", rat); + + GP_Print(&fb->context, NULL, 10, 12 + th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + white_pixel, black_pixel, "1:%3.3f", rat); + + GP_Print(&fb->context, NULL, 11, 15 + 2 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + black_pixel, white_pixel, "%s", img_name(params->img_path)); + + GP_Print(&fb->context, NULL, 10, 14 + 2 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + white_pixel, black_pixel, "%s", img_name(params->img_path)); + return NULL; }
static pthread_t loader_thread = (pthread_t)0; -static struct loader_params params;
-static void show_image(const char *img_path, int clear) +static void show_image(struct loader_params *params) { int ret; - params.img_path = img_path; - params.clear = clear; - /* stop previous loader thread */ if (loader_thread) { abort_flag = 1; @@ -182,7 +243,7 @@ static void show_image(const char *img_path, int clear) abort_flag = 0; }
- ret = pthread_create(&loader_thread, NULL, image_loader, (void*)¶ms); + ret = pthread_create(&loader_thread, NULL, image_loader, (void*)params);
if (ret) { fprintf(stderr, "Failed to start thread: %sn", strerror(ret)); @@ -204,11 +265,17 @@ int main(int argc, char *argv[]) GP_InputDriverLinux *drv = NULL; char *input_dev = NULL; int sleep_sec = -1; - + struct loader_params params = {NULL, 0, 0, 0}; int opt;
- while ((opt = getopt(argc, argv, "i:s:r:")) != -1) { + while ((opt = getopt(argc, argv, "Ii:Ps:r:")) != -1) { switch (opt) { + case 'I': + params.show_info = 1; + break; + case 'P': + params.show_progress = 1; + break; case 'i': input_dev = optarg; break; @@ -258,10 +325,14 @@ int main(int argc, char *argv[]) black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &fb->context); white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &fb->context);
+ GP_Fill(&fb->context, black_pixel); + int argf = optind; int argn = argf;
- show_image(argv[argf], 1); + params.show_progress_once = 1; + params.img_path = argv[argf]; + show_image(¶ms);
/* Initalize select */ fd_set rfds; @@ -288,7 +359,8 @@ int main(int argc, char *argv[]) if (argn >= argc) argn = argf; - show_image(argv[argn], 0); + params.img_path = argv[argn]; + show_image(¶ms); break; default: while (GP_InputDriverLinuxRead(drv)); @@ -302,7 +374,8 @@ int main(int argc, char *argv[]) if (argn >= argc) argn = argf; - show_image(argv[argn], 0); + params.img_path = argv[argn]; + show_image(¶ms); }
/* Read and parse events */ @@ -318,11 +391,22 @@ int main(int argc, char *argv[]) continue;
switch (ev.val.key.key) { + case GP_KEY_I: + params.show_info = !params.show_info; + + params.show_progress_once = 1; + show_image(¶ms); + break; + case GP_KEY_P: + params.show_progress = !params.show_progress; + break; case GP_KEY_R: rotate += 90; if (rotate > 270) rotate = 0; - show_image(argv[argn], 1); + + params.show_progress_once = 1; + show_image(¶ms); break; case GP_KEY_ESC: case GP_KEY_ENTER: @@ -330,20 +414,28 @@ int main(int argc, char *argv[]) GP_FramebufferExit(fb); return 0; break; + case GP_KEY_RIGHT: case GP_KEY_UP: case GP_KEY_SPACE: argn++; if (argn >= argc) argn = argf; - show_image(argv[argn], 1); + + params.show_progress_once = 1; + params.img_path = argv[argn]; + show_image(¶ms); break; + case GP_KEY_BACKSPACE: + case GP_KEY_LEFT: case GP_KEY_DOWN: argn--;
if (argn < argf) argn = argc - 1;
- show_image(argv[argn], 1); + params.show_progress_once = 1; + params.img_path = argv[argn]; + show_image(¶ms); break; } break;
-----------------------------------------------------------------------
Summary of changes: demos/fbshow/fbshow.c | 156 +++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 124 insertions(+), 32 deletions(-)
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.