From e0e1a1f26c7967b075ae33c8e994919bafa7808d Mon Sep 17 00:00:00 2001 From: sam Date: Fri, 16 Jan 2009 14:23:23 +0000 Subject: [PATCH] storyboard.c: add decorations around thumbnails git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3352 92316355-f0b4-4df1-b90c-862c8a59935f --- examples/storyboard.c | 53 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/examples/storyboard.c b/examples/storyboard.c index ba3c589..09f4bf0 100644 --- a/examples/storyboard.c +++ b/examples/storyboard.c @@ -24,7 +24,7 @@ #include -#define STEP 15 +#define STEP 12 #define TWIDTH 90 #define THEIGHT 60 @@ -33,6 +33,7 @@ #define NTHUMBS (TCOLS*TROWS) static int similar(uint8_t *img1, uint8_t *img2); +static void decorate(uint8_t *img); int main(int argc, char *argv[]) { @@ -135,6 +136,8 @@ int main(int argc, char *argv[]) sws_scale(sws, frame->data, frame->linesize, 0, ctx->height, &start, &pitch); + decorate(start); + if(idx > 0) { uint8_t *prev; @@ -167,8 +170,8 @@ static int similar(uint8_t *img1, uint8_t *img2) { int x, y, t, a, b, changed = 0; - for(y = 1; y < THEIGHT - 1; y++) - for(x = 1; x < TWIDTH - 1; x++) + for(y = 2; y < THEIGHT - 2; y++) + for(x = 2; x < TWIDTH - 2; x++) { int offset = y * TWIDTH * TCOLS + x; int ok = 0; @@ -210,3 +213,47 @@ static int similar(uint8_t *img1, uint8_t *img2) return changed < (TWIDTH * THEIGHT * 10 / 100); } +static void decorate(uint8_t *img) +{ + static int const hi = 200; + static int const lo = 50; + static int const mid = (hi + lo) / 2; + int x, y; + + for(y = 0; y < THEIGHT; y++) + { + img[(y * TWIDTH * TCOLS) * 4] = hi; + img[(y * TWIDTH * TCOLS) * 4 + 1] = hi; + img[(y * TWIDTH * TCOLS) * 4 + 2] = hi; + img[(y * TWIDTH * TCOLS + TWIDTH - 1) * 4] = lo; + img[(y * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 1] = lo; + img[(y * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 2] = lo; + } + + for(x = 0; x < TWIDTH; x++) + { + img[x * 4] = hi; + img[x * 4 + 1] = hi; + img[x * 4 + 2] = hi; + img[((THEIGHT - 1) * TWIDTH * TCOLS + x) * 4] = lo; + img[((THEIGHT - 1) * TWIDTH * TCOLS + x) * 4 + 1] = lo; + img[((THEIGHT - 1) * TWIDTH * TCOLS + x) * 4 + 2] = lo; + } + + img[0] = (mid + hi) / 2; + img[1] = (mid + hi) / 2; + img[2] = (mid + hi) / 2; + + img[(TWIDTH - 1) * 4 + 0] = mid; + img[(TWIDTH - 1) * 4 + 1] = mid; + img[(TWIDTH - 1) * 4 + 2] = mid; + + img[((THEIGHT - 1) * TWIDTH * TCOLS) * 4 + 0] = mid; + img[((THEIGHT - 1) * TWIDTH * TCOLS) * 4 + 1] = mid; + img[((THEIGHT - 1) * TWIDTH * TCOLS) * 4 + 2] = mid; + + img[((THEIGHT - 1) * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 0] = (mid + lo) / 2; + img[((THEIGHT - 1) * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 1] = (mid + lo) / 2; + img[((THEIGHT - 1) * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 2] = (mid + lo) / 2; +} +