1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
//============================================================================
// Name : CreateAtmelDemoBin.cpp
// Author : Tony.Liu
// Version :
// Copyright : Your copyright notice
// Description : CreateAtmelDemoBin, c,c++ mix using for EasyBMP and regex compilation
//============================================================================
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "profile.h"
#include "CreateDemoBin.h"
#include "DemoBinHeader.h"
//show usage help
void ShowHelp(const char * exeName)
{
printf("\n");
printf("Usage: %s [options] <PPTpathAndnameWithoutExtName>", exeName);
printf("\n For example, sam3demo.ppt, after running VBS macro in PowerPoint, ");
printf("\n copy this file under the same directory, then Run:\n");
printf("\n %s sam3demo", exeName);
printf("\n Options:");
printf("\n --help, show this information");
printf("\n -profile <EK-board-name>, build-in option sets, default board name is at91sam3u-ek");
printf("\n -profile help, display all build-in profile details");
printf("\n -width <resizedwith>, default is 320 pixel");
printf("\n -height <resizedheight>, default is 240 pixel");
printf("\n -bitdepth <bitdepth>, default is 16 bit");
printf("\n -rotate <clockwise_angel>, times of 90 degree within 360, default is 270 degree");
printf("\n -noreversebitmaporder, keep bitmap data original order, default reverse the order for at91sam3u-ek");
printf("\n");
}
//show profile details
void ShowProfiles()
{
printf("\n\r profiles details:");
printf("\n\r -profile at91sam3u-ek <-> -bitdepth 16 -width 320 -height 240 -rotate 0");
}
//seek matched profile
static int ProfileOption(char *pProfile, BMPConvOpt *const pOption )
{
unsigned int j;
unsigned int i = sizeof(profile)/sizeof(Profile);
for(j = 0; j < i; j++) {
if(strcmp(pProfile, profile[j].pProfileName) == 0) {
pOption->bitdepth = profile[j].options.bitdepth;
pOption->width = profile[j].options.width;
pOption->height = profile[j].options.height;
pOption->rotateangle = profile[j].options.rotateangle;
pOption->reversebitmaporder = profile[j].options.reversebitmaporder;
return 0;
}
}
return 1;
}
//get conversion setting option from execution arguments
static void GetOptsFromargv(int argc, char **argv, BMPConvOpt *pOption)
{
int i;
//set default option value, it is used for at91SAM3u-ek demo on SDCARD or NANDFLASH
pOption->bitdepth = 16;
pOption->width = 320;
pOption->height = 240;
pOption->rotateangle = 270;
pOption->reversebitmaporder = 1;
#if defined(MOVIE_MERGE_on)
pOption->mvSlideNumber = 5;
#endif
#if defined(SLIDESHOW_MERGE_on)
pOption->ssPageNumber = MAXSLIDESPERBIN;
pOption->ssBitdepth = 16;
pOption->ssWidth = 320;
pOption->ssHeight = 240;
pOption->ssRotateangle = 270;
pOption->ssReverseBmpOrder = 1;
#endif
//parse argument
for(i=1;i<argc-1;++i) {
if(strcmp(argv[i], "-profile")==0) {
if(!ProfileOption(argv[++i], pOption)) {
break;
}
continue;
}
if(strcmp(argv[i], "-width")== 0) {
pOption->width = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-height")==0) {
pOption->height = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-bitdepth")==0) {
pOption->bitdepth = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-rotate")==0) {
pOption->rotateangle = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-noreversebitmaporder")==0) {
pOption->reversebitmaporder = 0;
continue;
}
#if defined(MOVIE_MERGE_on)
if(strcmp(argv[i], "-movieSlideNumber")==0) {
pOption->mvSlideNumber = (unsigned int)floor(atof(argv[++i]));
continue;
}
#endif
#if defined(SLIDESHOW_MERGE_on)
if(strcmp(argv[i], "-ssPageNumber")== 0) {
pOption->ssPageNumber = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-ssWidth")== 0) {
pOption->ssWidth = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-ssHeight")==0) {
pOption->ssHeight = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-ssBitdepth")==0) {
pOption->ssBitdepth = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-ssRotate")==0) {
pOption->ssRotateangle = (unsigned int)floor(atof(argv[++i]));
continue;
}
if(strcmp(argv[i], "-ssNoreversebitmaporder")==0) {
pOption->ssReverseBmpOrder = 0;
continue;
}
#endif
}
printf("\n *****Prepare: Converstion will use following options:");
#if defined(SLIDESHOW_MERGE_on)
printf("\n Bitdepth: %u; Width: %u; Height: %u; rotate angel: %u; reversebitorder: %s; SS Slide number: %u; SSBitdepth: %u; SSWidth: %u; SSHeight: %u; SS rotate angel: %u;",\
pOption->bitdepth,\
pOption->width,\
pOption->height,\
pOption->rotateangle,\
pOption->reversebitmaporder ? "yes":"no",\
pOption->ssPageNumber,\
pOption->ssBitdepth,\
pOption->ssWidth,\
pOption->ssHeight,\
pOption->ssRotateangle);
#else
printf("\n Bitdepth: %u; Width: %u; Height: %u; rotate angel: %u; reversebitorder: %s;",\
pOption->bitdepth,\
pOption->width,\
pOption->height,\
pOption->rotateangle,\
pOption->reversebitmaporder ? "yes":"no");
#endif
}
////////////////////////////////////////////////////////////////////
//Main portal
///////////////////////////////////////////////////////////////////
int main(int argc, char**argv)
{
bool bRet=true;
BMPConvOpt option;
//Show usage help
if(argc == 1 || \
strcmp(argv[1], "--help")==0 || \
strcmp(argv[1], "/?")==0 \
)
{
ShowHelp(argv[0]);
return 1;
}
if(argc == 3 && strcmp(argv[1], "-profile") == 0 && strcmp(argv[2], "help") == 0) {
ShowProfiles();
return 0;
}
//parse execution options ready for following conversion
GetOptsFromargv(argc, argv, &option);
//Init filename variables based on command argument
printf("\n\n *****Step1: Create Neccesary file names!");
Step1_CreateFileNameVars(argv[argc-1]);
#if 0
//check if created file names are correct
printf("\n\r %s ", pptScriptLink);
printf("\n\r %s", pAtmlDemoBin);
printf("\n\r %s", pBinContent);
for(int i = 0; i< MAXSLIDESPERBIN; ++i) {
printf("\n\r %s", pptSlidesBmp[i]);
}
for(int j=0; j < MAXSLIDESPERBIN; ++j) {
printf("\n\r %s", pptSlides320x240Bmp[j]);
}
exit(0);
#endif
//Parsed generated Script file
#if !defined(MOVIE_MERGE_on)
printf("\n\n *****Step2: Parse PPT slide information txt file");
bRet &= Step2_ProcessPPTInfoFile(&option);
printf("\n ****Step2 Result: %s ****", bRet?"Success":"Failure");
#endif
//Resize and rotate saved slide bmp files
printf("\n\n *****Step3: Resize,rotate and reset bit depth of slide bmp file");
printf("\nbitdepth %u, width %u, height %u, rotateangle %u",option.bitdepth, option.width, option.height, option.rotateangle);
bRet &= Step3_ResizeAndRotateSlideBMP(&option);
printf("\n ****Step3 Result: %s ****", bRet?"Success":"Failure");
//Create Atmel Demo bin file
printf("\n\n *****Step4: Create demo bin from above step generated information");
bRet &= Step4_GenerateDemoBin(&option);
printf("\n ****Step4 Result: %s ****", bRet?"Success":"Failure");
#if !defined(MOVIE_MERGE_on)
//Show each bmp bitmap file header in demo bin file
printf("\n\n *****Done: Check bitmap file information in generated demo bin");
ShowEachBmpHeader();
#endif
if(bRet) {
printf("\n\n -----------Result: Creating demo bin file succeeds!-----------");
return 0;
}
else {
printf("\n\n ------------Result: Fail to Create right demo bin!-----------");
return 1;
}
}
|