@@ -42,15 +42,16 @@ static const struct option longOpts[] = {
42
42
{"info" , no_argument , 0 , 'i' },
43
43
{"no-keys" , no_argument , 0 , 'k' },
44
44
{"soft" , no_argument , 0 , 's' },
45
+ {"ignore-exif" , no_argument , 0 , 0x103 },
45
46
{0 , 0 , 0 , 0 }
46
47
};
47
48
48
49
static ILCLIENT_T * client = NULL ;
49
50
static char end = 0 ;
50
51
51
- static char info = 0 , blank = 0 , soft = 0 , keys = 1 , center = 0 ;
52
+ static char info = 0 , blank = 0 , soft = 0 , keys = 1 , center = 0 , exifOrient = 1 , mirror = 0 ;
52
53
static uint32_t sWidth , sHeight ;
53
- static int initRotation = 0 ;
54
+ static int initRotation = 0 , rotateInc = 90 ;
54
55
55
56
static OMX_RENDER render = INIT_OMX_RENDER , render2 ;
56
57
static OMX_RENDER * pCurRender = & render ;
@@ -159,7 +160,8 @@ void printUsage(const char *progr){
159
160
printf (" -d --display n Display number\n" );
160
161
printf (" -i --info Print some additional infos\n" );
161
162
printf (" -k --no-keys Disable keyboard input\n" );
162
- printf (" -s --soft Force software decoding\n\n" );
163
+ printf (" -s --soft Force software decoding\n" );
164
+ printf (" --ignore-exif Ignore exif orientation\n\n" );
163
165
printf ("KEY CONFIGURATION:\n\n" );
164
166
printf (" ESC, q : Quit\n" );
165
167
printf (" LEFT : Previous image\n" );
@@ -211,7 +213,43 @@ static int renderImage(IMAGE *image, ANIM_IMAGE *anim){
211
213
}
212
214
}
213
215
214
- dispConfig .rotation = initRotation ;
216
+ dispConfig .rotation = 0 ;
217
+ switch (exifOrient ){
218
+ case 7 :
219
+ dispConfig .rotation += 90 ;
220
+ case 4 :
221
+ dispConfig .rotation += 90 ;
222
+ case 5 :
223
+ dispConfig .rotation += 90 ;
224
+ case 2 :
225
+ dispConfig .rotation += (360 - initRotation );
226
+ if (mirror == 0 ){
227
+ rotateInc = 270 ;
228
+ dispConfig .configFlags |= OMX_DISP_CONFIG_FLAG_MIRROR ;
229
+ }else {
230
+ rotateInc = 90 ;
231
+ dispConfig .configFlags &= ~OMX_DISP_CONFIG_FLAG_MIRROR ;
232
+ }
233
+ break ;
234
+ case 8 :
235
+ dispConfig .rotation += 90 ;
236
+ case 3 :
237
+ dispConfig .rotation += 90 ;
238
+ case 6 :
239
+ dispConfig .rotation += 90 ;
240
+ case 1 :
241
+ case 0 :
242
+ dispConfig .rotation += initRotation ;
243
+ if (mirror == 1 ){
244
+ rotateInc = 270 ;
245
+ dispConfig .configFlags |= OMX_DISP_CONFIG_FLAG_MIRROR ;
246
+ }else {
247
+ rotateInc = 90 ;
248
+ dispConfig .configFlags &= ~OMX_DISP_CONFIG_FLAG_MIRROR ;
249
+ }
250
+ break ;
251
+ }
252
+ dispConfig .rotation %=360 ;
215
253
216
254
if (anim -> frameCount < 2 ){
217
255
ret = omxRenderImage (pCurRender , image );
@@ -238,6 +276,8 @@ static int decodeImage(const char *filePath, IMAGE *image, ANIM_IMAGE *anim){
238
276
size_t size = 0 ;
239
277
char magNum [8 ];
240
278
279
+ exifOrient = (exifOrient == 0 ) ? 0 : 1 ;
280
+
241
281
if (strncmp (filePath , "http://" , 7 ) == 0 || strncmp (filePath , "https://" , 8 ) == 0 ){
242
282
if (info )
243
283
printf ("Open Url: %s\n" , filePath );
@@ -275,6 +315,9 @@ static int decodeImage(const char *filePath, IMAGE *image, ANIM_IMAGE *anim){
275
315
return ret ;
276
316
}
277
317
318
+ if (exifOrient != 0 )
319
+ exifOrient = jInfo .orientation ;
320
+
278
321
rewind (imageFile );
279
322
280
323
if (soft || jInfo .mode == JPEG_MODE_PROGRESSIVE || jInfo .nColorComponents != 3 ){
@@ -420,8 +463,7 @@ int main(int argc, char *argv[]){
420
463
dispConfig .rotation = initRotation ;
421
464
break ;
422
465
case 'm' :
423
- dispConfig .configFlags |= OMX_DISP_CONFIG_FLAG_MIRROR ;
424
- break ;
466
+ mirror = 1 ; break ;
425
467
case 'l' :
426
468
dispConfig .layer = strtol (optarg , NULL , 10 );
427
469
break ;
@@ -434,6 +476,8 @@ int main(int argc, char *argv[]){
434
476
keys = 0 ; break ;
435
477
case 's' :
436
478
soft = 1 ; break ;
479
+ case 0x103 :
480
+ exifOrient = 0 ; break ;
437
481
default :
438
482
return EXIT_FAILURE ;
439
483
}
@@ -544,6 +588,7 @@ int main(int argc, char *argv[]){
544
588
}else if (c == 'm' || c == 'M' ){
545
589
tcflush (0 , TCIFLUSH );
546
590
dispConfig .configFlags ^= OMX_DISP_CONFIG_FLAG_MIRROR ;
591
+ rotateInc = (rotateInc + 180 )%360 ;
547
592
ret = setOmxDisplayConfig (pCurRender );
548
593
if (ret != 0 ){
549
594
fprintf (stderr , "dispConfig set returned 0x%x\n" , ret );
@@ -556,18 +601,14 @@ int main(int argc, char *argv[]){
556
601
c = getch (1 );
557
602
tcflush (0 , TCIFLUSH );
558
603
if (c == 0x41 ){
559
- if (dispConfig .rotation > 0 )
560
- dispConfig .rotation -= 90 ;
561
- else
562
- dispConfig .rotation = 270 ;
604
+ dispConfig .rotation = (dispConfig .rotation + 360 - rotateInc )%360 ;
563
605
ret = setOmxDisplayConfig (pCurRender );
564
606
if (ret != 0 ){
565
607
fprintf (stderr , "dispConfig set returned 0x%x\n" , ret );
566
608
break ;
567
609
}
568
610
}else if (c == 0x42 ){
569
- dispConfig .rotation += 90 ;
570
- dispConfig .rotation %=360 ;
611
+ dispConfig .rotation = (dispConfig .rotation + rotateInc )%360 ;
571
612
ret = setOmxDisplayConfig (pCurRender );
572
613
if (ret != 0 ){
573
614
fprintf (stderr , "dispConfig set returned 0x%x\n" , ret );
0 commit comments