Skip to content

Commit fb59e54

Browse files
committed
rotation fixed
1 parent 5008e64 commit fb59e54

File tree

1 file changed

+12
-28
lines changed

1 file changed

+12
-28
lines changed

raspi2png.c

+12-28
Original file line numberDiff line numberDiff line change
@@ -202,22 +202,6 @@ main(
202202

203203
bcm_host_init();
204204

205-
//-------------------------------------------------------------------
206-
//
207-
// When the display is rotate (either 90 or 270 degrees) we need to
208-
// swap the width and height of the snapshot
209-
//
210-
211-
char response[1024];
212-
int displayRotated = 0;
213-
214-
if (vc_gencmd(response, sizeof(response), "get_config int") == 0)
215-
{
216-
vc_gencmd_number_property(response,
217-
"display_rotate",
218-
&displayRotated);
219-
}
220-
221205
//-------------------------------------------------------------------
222206

223207
if (delay)
@@ -279,14 +263,14 @@ main(
279263
}
280264

281265
//-------------------------------------------------------------------
282-
// only need to check low bit of displayRotated (value of 1 or 3).
266+
// only need to check low bit of modeInfo.transform (value of 1 or 3).
283267
// If the display is rotated either 90 or 270 degrees (value 1 or 3)
284268
// the width and height need to be transposed.
285269

286270
int32_t dmxWidth = pngWidth;
287271
int32_t dmxHeight = pngHeight;
288272

289-
if (displayRotated & 1)
273+
if (modeInfo.transform & 1)
290274
{
291275
dmxWidth = pngHeight;
292276
dmxHeight = pngWidth;
@@ -370,11 +354,11 @@ main(
370354
int32_t dmxXoffset = 0;
371355
int32_t dmxYoffset = 0;
372356

373-
switch (displayRotated & 3)
357+
switch (modeInfo.transform & 3)
374358
{
375359
case 0: // 0 degrees
376360

377-
if (displayRotated & 0x20000) // flip vertical
361+
if (modeInfo.transform & 0x20000) // flip vertical
378362
{
379363
dmxYoffset = (dmxHeight - j - 1) * dmxPitch;
380364
}
@@ -388,7 +372,7 @@ main(
388372
case 1: // 90 degrees
389373

390374

391-
if (displayRotated & 0x20000) // flip vertical
375+
if (modeInfo.transform & 0x20000) // flip vertical
392376
{
393377
dmxXoffset = j * dmxBytesPerPixel;
394378
}
@@ -401,7 +385,7 @@ main(
401385

402386
case 2: // 180 degrees
403387

404-
if (displayRotated & 0x20000) // flip vertical
388+
if (modeInfo.transform & 0x20000) // flip vertical
405389
{
406390
dmxYoffset = j * dmxPitch;
407391
}
@@ -414,7 +398,7 @@ main(
414398

415399
case 3: // 270 degrees
416400

417-
if (displayRotated & 0x20000) // flip vertical
401+
if (modeInfo.transform & 0x20000) // flip vertical
418402
{
419403
dmxXoffset = (dmxWidth - j - 1) * dmxBytesPerPixel;
420404
}
@@ -433,11 +417,11 @@ main(
433417
+ (i * pngBytesPerPixel)
434418
+ (j * pngPitch);
435419

436-
switch (displayRotated & 3)
420+
switch (modeInfo.transform & 3)
437421
{
438422
case 0: // 0 degrees
439423

440-
if (displayRotated & 0x10000) // flip horizontal
424+
if (modeInfo.transform & 0x10000) // flip horizontal
441425
{
442426
dmxXoffset = (dmxWidth - i - 1) * dmxBytesPerPixel;
443427
}
@@ -450,7 +434,7 @@ main(
450434

451435
case 1: // 90 degrees
452436

453-
if (displayRotated & 0x10000) // flip horizontal
437+
if (modeInfo.transform & 0x10000) // flip horizontal
454438
{
455439
dmxYoffset = (dmxHeight - i - 1) * dmxPitch;
456440
}
@@ -463,7 +447,7 @@ main(
463447

464448
case 2: // 180 degrees
465449

466-
if (displayRotated & 0x10000) // flip horizontal
450+
if (modeInfo.transform & 0x10000) // flip horizontal
467451
{
468452
dmxXoffset = i * dmxBytesPerPixel;
469453
}
@@ -476,7 +460,7 @@ main(
476460

477461
case 3: // 270 degrees
478462

479-
if (displayRotated & 0x10000) // flip horizontal
463+
if (modeInfo.transform & 0x10000) // flip horizontal
480464
{
481465
dmxYoffset = i * dmxPitch;
482466
}

0 commit comments

Comments
 (0)