Selaa lähdekoodia

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
master
sam 16 vuotta sitten
vanhempi
commit
e0e1a1f26c
1 muutettua tiedostoa jossa 50 lisäystä ja 3 poistoa
  1. +50
    -3
      examples/storyboard.c

+ 50
- 3
examples/storyboard.c Näytä tiedosto

@@ -24,7 +24,7 @@

#include <pipi.h>

#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;
}


Ladataan…
Peruuta
Tallenna