Ignore:
Timestamp:
Jan 16, 2009, 3:23:23 PM (12 years ago)
Author:
Sam Hocevar
Message:

storyboard.c: add decorations around thumbnails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/examples/storyboard.c

    r3351 r3352  
    2525#include <pipi.h>
    2626
    27 #define STEP 15
     27#define STEP 12
    2828
    2929#define TWIDTH 90
     
    3434
    3535static int similar(uint8_t *img1, uint8_t *img2);
     36static void decorate(uint8_t *img);
    3637
    3738int main(int argc, char *argv[])
     
    136137                      &start, &pitch);
    137138
     139            decorate(start);
     140
    138141            if(idx > 0)
    139142            {
     
    168171    int x, y, t, a, b, changed = 0;
    169172
    170     for(y = 1; y < THEIGHT - 1; y++)
    171         for(x = 1; x < TWIDTH - 1; x++)
     173    for(y = 2; y < THEIGHT - 2; y++)
     174        for(x = 2; x < TWIDTH - 2; x++)
    172175        {
    173176            int offset = y * TWIDTH * TCOLS + x;
     
    211214}
    212215
     216static void decorate(uint8_t *img)
     217{
     218    static int const hi = 200;
     219    static int const lo = 50;
     220    static int const mid = (hi + lo) / 2;
     221    int x, y;
     222
     223    for(y = 0; y < THEIGHT; y++)
     224    {
     225        img[(y * TWIDTH * TCOLS) * 4] = hi;
     226        img[(y * TWIDTH * TCOLS) * 4 + 1] = hi;
     227        img[(y * TWIDTH * TCOLS) * 4 + 2] = hi;
     228        img[(y * TWIDTH * TCOLS + TWIDTH - 1) * 4] = lo;
     229        img[(y * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 1] = lo;
     230        img[(y * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 2] = lo;
     231    }
     232
     233    for(x = 0; x < TWIDTH; x++)
     234    {
     235        img[x * 4] = hi;
     236        img[x * 4 + 1] = hi;
     237        img[x * 4 + 2] = hi;
     238        img[((THEIGHT - 1) * TWIDTH * TCOLS + x) * 4] = lo;
     239        img[((THEIGHT - 1) * TWIDTH * TCOLS + x) * 4 + 1] = lo;
     240        img[((THEIGHT - 1) * TWIDTH * TCOLS + x) * 4 + 2] = lo;
     241    }
     242
     243    img[0] = (mid + hi) / 2;
     244    img[1] = (mid + hi) / 2;
     245    img[2] = (mid + hi) / 2;
     246
     247    img[(TWIDTH - 1) * 4 + 0] = mid;
     248    img[(TWIDTH - 1) * 4 + 1] = mid;
     249    img[(TWIDTH - 1) * 4 + 2] = mid;
     250
     251    img[((THEIGHT - 1) * TWIDTH * TCOLS) * 4 + 0] = mid;
     252    img[((THEIGHT - 1) * TWIDTH * TCOLS) * 4 + 1] = mid;
     253    img[((THEIGHT - 1) * TWIDTH * TCOLS) * 4 + 2] = mid;
     254
     255    img[((THEIGHT - 1) * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 0] = (mid + lo) / 2;
     256    img[((THEIGHT - 1) * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 1] = (mid + lo) / 2;
     257    img[((THEIGHT - 1) * TWIDTH * TCOLS + TWIDTH - 1) * 4 + 2] = (mid + lo) / 2;
     258}
     259
Note: See TracChangeset for help on using the changeset viewer.