add test movie generator modes black and white
Stefan Schuermans

Stefan Schuermans commited on 2014-05-10 10:26:57
Showing 1 changed files, with 31 additions and 2 deletions.

... ...
@@ -13,9 +13,15 @@ static void gen_test_movie(stBlinkenMovie **ppMovie, const char *str_format,
13 13
                            const char *str_mode, const char *str_duration)
14 14
 {
15 15
   unsigned int height, width, channels, colors;
16
-  enum { ModeNone, ModeDots, ModeLines, ModeTrans } mode = ModeNone;
16
+  enum {
17
+    ModeNone, ModeBlack, ModeWhite, ModeDots, ModeLines, ModeTrans
18
+  } mode = ModeNone;
17 19
   int duration;
18 20
 
21
+  if (strcmp(str_mode, "black") == 0)
22
+    mode = ModeBlack;
23
+  if (strcmp(str_mode, "white") == 0)
24
+    mode = ModeWhite;
19 25
   if (strcmp(str_mode, "dots") == 0)
20 26
     mode = ModeDots;
21 27
   if (strcmp(str_mode, "lines") == 0)
... ...
@@ -50,6 +56,28 @@ static void gen_test_movie(stBlinkenMovie **ppMovie, const char *str_format,
50 56
       case ModeNone:
51 57
         break;
52 58
 
59
+      case ModeBlack:
60
+        pFrame =
61
+            BlinkenFrameNew(height, width, channels, colors - 1,
62
+                            duration);
63
+        for (yy = 0; yy < height; yy++)
64
+          for (xx = 0; xx < width; xx++)
65
+            for (cc = 0; cc < channels; cc++)
66
+              BlinkenFrameSetPixel(pFrame, yy, xx, cc, 0);
67
+        BlinkenMovieAppendFrame(*ppMovie, pFrame);
68
+        break;
69
+
70
+      case ModeWhite:
71
+        pFrame =
72
+            BlinkenFrameNew(height, width, channels, colors - 1,
73
+                            duration);
74
+        for (yy = 0; yy < height; yy++)
75
+          for (xx = 0; xx < width; xx++)
76
+            for (cc = 0; cc < channels; cc++)
77
+              BlinkenFrameSetPixel(pFrame, yy, xx, cc, colors - 1);
78
+        BlinkenMovieAppendFrame(*ppMovie, pFrame);
79
+        break;
80
+
53 81
       case ModeDots:
54 82
         for (c = 0; c < channels; c++)
55 83
           for (y = 0; y < height; y++)
... ...
@@ -201,7 +229,8 @@ int main(int argCnt, char **args)
201 229
            "     reverse movie\n"
202 230
            "  -d <first> <count>\n"
203 231
            "     delete frames\n"
204
-           "  -t <width>x<height>-<channels>/<colors> [dots|lines|trans] <duration>\n"
232
+           "  -t <width>x<height>-<channels>/<colors>\n"
233
+           "     [black|white|dots|lines|trans] <duration>\n"
205 234
            "     generate a test movie\n"
206 235
            "  -C <file> <src-x>,<src-y> <width>x<height> <dest-x>,<dest-y>\n"
207 236
            "     copy rectangular section of other movie\n"
208 237