Christian Heimke commited on 2011-07-15 09:01:27
Showing 11 changed files, with 184 additions and 37 deletions.
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
... | ... |
@@ -14,12 +14,14 @@ |
14 | 14 |
int main( int argCnt, char * * args ) |
15 | 15 |
{ |
16 | 16 |
stBlinkenMovie * pMovie; |
17 |
+ int i; |
|
17 | 18 |
char * str; |
19 |
+ unsigned int height, width, channels, colors; |
|
18 | 20 |
|
19 | 21 |
//print info |
20 |
- printf( "BlinkenLib\n" |
|
21 |
- "version 0.1 date 2004-11-25\n" |
|
22 |
- "Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info>\n" |
|
22 |
+ printf( "BlinkenLib - BlinkenConv\n" |
|
23 |
+ "version 0.2 date 2005-01-27\n" |
|
24 |
+ "Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info>\n" |
|
23 | 25 |
"Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n" |
24 | 26 |
"a blinkenarea.org project\n" |
25 | 27 |
"powered by eventphone.de\n\n" ); |
... | ... |
@@ -27,39 +29,172 @@ int main( int argCnt, char * * args ) |
27 | 29 |
//print syntax |
28 | 30 |
if( argCnt <= 1 ) |
29 | 31 |
{ |
30 |
- printf( "syntax: ./BlinkenConv <input-file> [<output-file>]\n\n" |
|
31 |
- " - output files may be *.blm, *.bmm, *.bml, *.bbm\n\n" ); |
|
32 |
+ printf( "syntax: %s <parameter> [...]\n\n" |
|
33 |
+ "parameters:\n" |
|
34 |
+ " -i <file>\n" |
|
35 |
+ " read movie from file (*.blm, *.bmm, *.bml, *.bbm)\n" |
|
36 |
+ " -p\n" |
|
37 |
+ " print movie\n" |
|
38 |
+ " -r <width>x<height>-<channels>/<colors>\n" |
|
39 |
+ " resize movie\n" |
|
40 |
+ " -s <width>x<height>\n" |
|
41 |
+ " scale movie\n" |
|
42 |
+ " -o <file>\n" |
|
43 |
+ " write movie to file (*.blm, *.bmm, *.bml, *.bbm)\n\n" |
|
44 |
+ "old syntax: %s <input-file> [<output-file>]\n\n", |
|
45 |
+ args[0], args[0] ); |
|
46 |
+ return 0; |
|
32 | 47 |
} |
33 | 48 |
|
34 | 49 |
//no movie loaded |
35 | 50 |
pMovie = NULL; |
36 | 51 |
|
37 |
- //read movie |
|
38 |
- if( argCnt >= 2 ) |
|
39 |
- pMovie = BlinkenMovieLoad( args[1] ); |
|
52 |
+ //process parameters |
|
53 |
+ for( i = 1; i < argCnt; i++ ) |
|
54 |
+ { |
|
40 | 55 |
|
41 |
- //movie was loaded |
|
42 |
- if( pMovie != NULL ) |
|
56 |
+ //read movie |
|
57 |
+ if( strcmp( args[i], "-i" ) == 0 ) |
|
58 |
+ { |
|
59 |
+ if( i + 1 < argCnt ) |
|
43 | 60 |
{ |
61 |
+ i++; |
|
62 |
+ if( pMovie != NULL ) |
|
63 |
+ BlinkenMovieFree( pMovie ); |
|
64 |
+ pMovie = BlinkenMovieLoad( args[i] ); |
|
65 |
+ if( pMovie == NULL ) |
|
66 |
+ printf( "could not read movie \"%s\"\n", args[i] ); |
|
67 |
+ else |
|
68 |
+ printf( "movie \"%s\" read\n", args[i] ); |
|
69 |
+ } |
|
70 |
+ else |
|
71 |
+ printf( "missing input filename for \"-i\"\n" ); |
|
72 |
+ } |
|
73 |
+ |
|
44 | 74 |
//print movie |
45 |
- if( argCnt <= 2 ) |
|
75 |
+ else if( strcmp( args[i], "-p" ) == 0 ) |
|
76 |
+ { |
|
77 |
+ if( pMovie == NULL ) |
|
78 |
+ printf( "no movie loaded to print\n" ); |
|
79 |
+ else |
|
46 | 80 |
{ |
47 | 81 |
str = BlinkenMovieToString( pMovie ); |
48 |
- if( str != NULL ) |
|
82 |
+ if( str == NULL ) |
|
83 |
+ printf( "could not print movie\n" ); |
|
84 |
+ else |
|
49 | 85 |
{ |
50 | 86 |
printf( "%s", str ); |
51 | 87 |
free( str ); |
52 | 88 |
} |
53 | 89 |
} |
90 |
+ } |
|
54 | 91 |
|
55 |
- //save movie |
|
56 |
- if( argCnt >= 3 ) |
|
57 |
- BlinkenMovieSave( pMovie, args[2] ); |
|
92 |
+ //resize movie |
|
93 |
+ else if( strcmp( args[i], "-r" ) == 0 ) |
|
94 |
+ { |
|
95 |
+ if( i + 1 < argCnt ) |
|
96 |
+ { |
|
97 |
+ i++; |
|
98 |
+ if( sscanf( args[i], "%ux%u-%u/%u", &width, &height, &channels, &colors ) != 4 ) |
|
99 |
+ printf( "invalid movie format \"%s\"\n", args[i] ); |
|
100 |
+ else if( pMovie == NULL ) |
|
101 |
+ printf( "no movie loaded to resize\n" ); |
|
102 |
+ else |
|
103 |
+ { |
|
104 |
+ BlinkenMovieResize( pMovie, height, width, channels, colors - 1 ); |
|
105 |
+ printf( "movie resized to %ux%u-%u/%u\n", width, height, channels, colors ); |
|
106 |
+ } |
|
107 |
+ } |
|
108 |
+ else |
|
109 |
+ printf( "missing movie format for \"-r\"\n" ); |
|
110 |
+ } |
|
58 | 111 |
|
59 |
- //free movie |
|
112 |
+ //scale movie |
|
113 |
+ else if( strcmp( args[i], "-s" ) == 0 ) |
|
114 |
+ { |
|
115 |
+ if( i + 1 < argCnt ) |
|
116 |
+ { |
|
117 |
+ i++; |
|
118 |
+ if( sscanf( args[i], "%ux%u", &width, &height ) != 2 ) |
|
119 |
+ printf( "invalid movie dimensions \"%s\"\n", args[i] ); |
|
120 |
+ else if( pMovie == NULL ) |
|
121 |
+ printf( "no movie loaded to scale\n" ); |
|
122 |
+ else |
|
123 |
+ { |
|
124 |
+ BlinkenMovieScale( pMovie, height, width ); |
|
125 |
+ printf( "movie scaled to %ux%u\n", width, height ); |
|
126 |
+ } |
|
127 |
+ } |
|
128 |
+ else |
|
129 |
+ printf( "missing movie dimensions for \"-s\"\n" ); |
|
130 |
+ } |
|
131 |
+ |
|
132 |
+ //write movie |
|
133 |
+ else if( strcmp( args[i], "-o" ) == 0 ) |
|
134 |
+ { |
|
135 |
+ if( i + 1 < argCnt ) |
|
136 |
+ { |
|
137 |
+ i++; |
|
138 |
+ if( pMovie == NULL ) |
|
139 |
+ printf( "no movie loaded to write to \"%s\"\n", args[i] ); |
|
140 |
+ else |
|
141 |
+ if( BlinkenMovieSave( pMovie, args[i] ) < 0 ) |
|
142 |
+ printf( "could not write movie \"%s\"\n", args[i] ); |
|
143 |
+ else |
|
144 |
+ printf( "movie \"%s\" written\n", args[i] ); |
|
145 |
+ } |
|
146 |
+ else |
|
147 |
+ printf( "missing output filename for \"-o\"\n" ); |
|
148 |
+ } |
|
149 |
+ |
|
150 |
+ //old style input filename |
|
151 |
+ else if( i == 1 && args[i][0] != '-' ) |
|
152 |
+ { |
|
153 |
+ printf( "old style input filename \"%s\", better use \"-i %s\"\n", args[i], args[i] ); |
|
154 |
+ if( pMovie != NULL ) |
|
60 | 155 |
BlinkenMovieFree( pMovie ); |
61 |
- pMovie = NULL; |
|
156 |
+ pMovie = BlinkenMovieLoad( args[i] ); |
|
157 |
+ if( pMovie == NULL ) |
|
158 |
+ printf( "could not read movie \"%s\"\n", args[i] ); |
|
159 |
+ else |
|
160 |
+ printf( "movie \"%s\" read\n", args[i] ); |
|
161 |
+ } |
|
162 |
+ |
|
163 |
+ //old style output filename |
|
164 |
+ else if( i == 2 && args[i][0] != '-' ) |
|
165 |
+ { |
|
166 |
+ printf( "old style output filename \"%s\", better use \"-o %s\"\n", args[i], args[i] ); |
|
167 |
+ if( pMovie == NULL ) |
|
168 |
+ printf( "no movie loaded to write to \"%s\"\n", args[i] ); |
|
169 |
+ else |
|
170 |
+ if( BlinkenMovieSave( pMovie, args[i] ) < 0 ) |
|
171 |
+ printf( "could not write movie \"%s\"\n", args[i] ); |
|
172 |
+ else |
|
173 |
+ printf( "movie \"%s\" written\n", args[i] ); |
|
174 |
+ } |
|
175 |
+ |
|
176 |
+ //unknown parameter |
|
177 |
+ else |
|
178 |
+ printf( "unknown parameter \"%s\", call without parameters to get help\n", args[i] ); |
|
179 |
+ |
|
180 |
+ } //for( i ... |
|
181 |
+ |
|
182 |
+ //old style print |
|
183 |
+ if( argCnt == 2 && pMovie != NULL ) |
|
184 |
+ { |
|
185 |
+ str = BlinkenMovieToString( pMovie ); |
|
186 |
+ if( str == NULL ) |
|
187 |
+ printf( "could not print movie\n" ); |
|
188 |
+ else |
|
189 |
+ { |
|
190 |
+ printf( "%s", str ); |
|
191 |
+ free( str ); |
|
192 |
+ } |
|
62 | 193 |
} |
63 | 194 |
|
195 |
+ //free movie |
|
196 |
+ if( pMovie != NULL ) |
|
197 |
+ BlinkenMovieFree( pMovie ); |
|
198 |
+ |
|
64 | 199 |
return 0; |
65 | 200 |
} |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
... | ... |
@@ -535,6 +535,8 @@ stBlinkenMovie * BlinkenMovieLoadBlm( char * pFilename ) |
535 | 535 |
|
536 | 536 |
//open file |
537 | 537 |
pFile = fopen( pFilename, "rt" ); |
538 |
+ if( pFile == NULL ) |
|
539 |
+ return NULL; |
|
538 | 540 |
|
539 | 541 |
//read magic and size |
540 | 542 |
if( fscanf( pFile, " # BlinkenLights Movie %ux%u", &width, &height ) != 2 ) |
... | ... |
@@ -616,6 +618,8 @@ stBlinkenMovie * BlinkenMovieLoadBmm( char * pFilename ) |
616 | 618 |
|
617 | 619 |
//open file |
618 | 620 |
pFile = fopen( pFilename, "rt" ); |
621 |
+ if( pFile == NULL ) |
|
622 |
+ return NULL; |
|
619 | 623 |
|
620 | 624 |
//read magic and size |
621 | 625 |
if( fscanf( pFile, " # BlinkenMini Movie %ux%u", &width, &height ) != 2 ) |
... | ... |
@@ -700,6 +704,8 @@ stBlinkenMovie * BlinkenMovieLoadBml( char * pFilename ) |
700 | 704 |
|
701 | 705 |
//open file |
702 | 706 |
pFile = fopen( pFilename, "rt" ); |
707 |
+ if( pFile == NULL ) |
|
708 |
+ return NULL; |
|
703 | 709 |
|
704 | 710 |
//no movie yet - blm tag not yet found |
705 | 711 |
pMovie = NULL; |
... | ... |
@@ -1118,6 +1124,8 @@ stBlinkenMovie * BlinkenMovieLoadBbm( char * pFilename ) |
1118 | 1124 |
|
1119 | 1125 |
//open file |
1120 | 1126 |
pFile = fopen( pFilename, "rb" ); |
1127 |
+ if( pFile == NULL ) |
|
1128 |
+ return NULL; |
|
1121 | 1129 |
|
1122 | 1130 |
//read header |
1123 | 1131 |
if( fread( header, 1, 24, pFile ) != 24 ) |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
# BlinkenLib |
2 |
-# version 0.1 date 2004-11-25 |
|
3 |
-# Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+# version 0.2 date 2005-01-27 |
|
3 |
+# Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
# Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
# a blinkenarea.org project |
6 | 6 |
# powered by eventphone.de |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
/* BlinkenLib |
2 |
- * version 0.1 date 2004-11-25 |
|
3 |
- * Copyright (C) 2004: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 0.2 date 2005-01-27 |
|
3 |
+ * Copyright 2004-2005 Stefan Schuermans <1stein@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 | 6 |
* powered by eventphone.de |
7 | 7 |