@@ -143,23 +143,29 @@ void rotate_8bpp(uint8_t *src, uint8_t *dst, mp_lcd_sw_rotation_data_t *copy_dat
143
143
144
144
switch (copy_data -> rotation ) {
145
145
case LCD_ROTATION_90 :
146
+ uint32_t src_line_bytes ;
147
+ dst_height -= 1 ;
148
+
146
149
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
150
+ src_line_bytes = (y * src_bytes_per_line ) - offset ;
151
+
147
152
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
148
- i = y * src_bytes_per_line + x - offset ;
149
- j = (dst_height - 1 - x ) * dst_width + y ;
153
+ i = src_line_bytes + x ;
154
+ j = (( dst_height - x ) * dst_width ) + y ;
150
155
copy_8bpp (src + i , dst + j );
151
156
}
152
157
}
153
158
break ;
154
159
155
160
// MIRROR_X MIRROR_Y
156
161
case LCD_ROTATION_180 :
157
- LCD_UNUSED ( j ) ;
162
+ j = dst_width - 1 - x_start ;
158
163
LCD_UNUSED (src_bytes_per_line );
159
164
LCD_UNUSED (offset );
165
+ dst_height -= 1 ;
160
166
161
167
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
162
- i = (dst_height - 1 - y ) * dst_width + ( dst_width - 1 - x_start ) ;
168
+ i = (( dst_height - y ) * dst_width ) + j ;
163
169
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
164
170
copy_8bpp (src , dst + i );
165
171
src ++ ;
@@ -170,10 +176,16 @@ void rotate_8bpp(uint8_t *src, uint8_t *dst, mp_lcd_sw_rotation_data_t *copy_dat
170
176
171
177
// SWAP_XY MIRROR_X
172
178
case LCD_ROTATION_270 :
179
+ uint32_t m ;
180
+ uint32_t o ;
181
+
173
182
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
183
+ m = y * src_bytes_per_line ;
184
+ o = dst_width - 1 - y ;
185
+
174
186
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
175
- i = y * src_bytes_per_line + x - offset ;
176
- j = x * dst_width + dst_width - 1 - y ;
187
+ i = m + x ;
188
+ j = ( x * dst_width ) + o ;
177
189
copy_8bpp (src + i , dst + j );
178
190
}
179
191
}
@@ -219,10 +231,14 @@ void rotate_16bpp_swap_dither(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_d
219
231
break ;
220
232
221
233
case LCD_ROTATION_90 :
234
+ uint32_t src_line_bytes ;
235
+ dst_height -= 1 ;
236
+
222
237
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
238
+ src_line_bytes = (y * src_bytes_per_line ) - offset ;
223
239
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
224
- i = y * src_bytes_per_line + x - offset ;
225
- j = (dst_height - 1 - x ) * dst_width + y ;
240
+ i = src_line_bytes + x ;
241
+ j = (( dst_height - x ) * dst_width ) + y ;
226
242
rgb565_dither_byte_swap_pixel (CALC_THRESHOLD (x , y ), src + i , dst + j );
227
243
// copy_16bpp(src + i, dst + j);
228
244
}
@@ -231,12 +247,13 @@ void rotate_16bpp_swap_dither(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_d
231
247
232
248
// MIRROR_X MIRROR_Y
233
249
case LCD_ROTATION_180 :
234
- LCD_UNUSED ( j ) ;
250
+ j = dst_width - 1 - x_start ;
235
251
LCD_UNUSED (src_bytes_per_line );
236
252
LCD_UNUSED (offset );
253
+ dst_height -= 1 ;
237
254
238
255
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
239
- i = (dst_height - 1 - y ) * dst_width + ( dst_width - 1 - x_start ) ;
256
+ i = (( dst_height - y ) * dst_width ) + j ;
240
257
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
241
258
rgb565_dither_byte_swap_pixel (CALC_THRESHOLD (x , y ), src , dst + i );
242
259
@@ -249,10 +266,16 @@ void rotate_16bpp_swap_dither(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_d
249
266
250
267
// SWAP_XY MIRROR_X
251
268
case LCD_ROTATION_270 :
269
+ uint32_t m ;
270
+ uint32_t o ;
271
+
252
272
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
273
+ m = (y * src_bytes_per_line ) - offset ;
274
+ o = dst_width - 1 - y ;
275
+
253
276
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
254
- i = y * src_bytes_per_line + x - offset ;
255
- j = (x * dst_width + dst_width - 1 - y ) ;
277
+ i = m + x ;
278
+ j = (x * dst_width ) + o ;
256
279
rgb565_dither_byte_swap_pixel (CALC_THRESHOLD (x , y ), src + i , dst + j );
257
280
258
281
// copy_16bpp(src + i, dst + j);
@@ -300,10 +323,15 @@ void rotate_16bpp_dither(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_data_t
300
323
break ;
301
324
302
325
case LCD_ROTATION_90 :
326
+ uint32_t src_line_bytes ;
327
+ dst_height -= 1 ;
328
+
303
329
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
330
+ src_line_bytes = (y * src_bytes_per_line ) - offset ;
331
+
304
332
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
305
- i = y * src_bytes_per_line + x - offset ;
306
- j = (dst_height - 1 - x ) * dst_width + y ;
333
+ i = src_line_bytes + x ;
334
+ j = (( dst_height - x ) * dst_width ) + y ;
307
335
rgb565_dither_pixel (CALC_THRESHOLD (x , y ), src + i , dst + j );
308
336
309
337
// copy_16bpp(src + i, dst + j);
@@ -313,12 +341,13 @@ void rotate_16bpp_dither(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_data_t
313
341
314
342
// MIRROR_X MIRROR_Y
315
343
case LCD_ROTATION_180 :
316
- LCD_UNUSED ( j ) ;
344
+ j = dst_width - 1 - x_start ;
317
345
LCD_UNUSED (src_bytes_per_line );
318
346
LCD_UNUSED (offset );
347
+ dst_height -= 1 ;
319
348
320
349
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
321
- i = (dst_height - 1 - y ) * dst_width + ( dst_width - 1 - x_start ) ;
350
+ i = (( dst_height - y ) * dst_width ) + j ;
322
351
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
323
352
rgb565_dither_pixel (CALC_THRESHOLD (x , y ), src , dst + i );
324
353
@@ -331,10 +360,16 @@ void rotate_16bpp_dither(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_data_t
331
360
332
361
// SWAP_XY MIRROR_X
333
362
case LCD_ROTATION_270 :
363
+ uint32_t m ;
364
+ uint32_t o ;
365
+
334
366
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
367
+ m = (y * src_bytes_per_line ) - offset ;
368
+ o = dst_width - 1 - y ;
369
+
335
370
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
336
- i = y * src_bytes_per_line + x - offset ;
337
- j = (x * dst_width + dst_width - 1 - y ) ;
371
+ i = m + x ;
372
+ j = (x * dst_width ) + o ;
338
373
rgb565_dither_pixel (CALC_THRESHOLD (x , y ), src + i , dst + j );
339
374
340
375
// copy_16bpp(src + i, dst + j);
@@ -382,11 +417,13 @@ void rotate_16bpp_swap(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_data_t *
382
417
break ;
383
418
384
419
case LCD_ROTATION_90 :
420
+ uint32_t src_line_bytes ;
421
+ dst_height -= 1 ;
422
+
385
423
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
386
424
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
387
- i = y * src_bytes_per_line + x - offset ;
388
- j = (dst_height - 1 - x ) * dst_width + y ;
389
-
425
+ i = src_line_bytes + x ;
426
+ j = ((dst_height - x ) * dst_width ) + y ;
390
427
* (dst + j ) = (* (src + i ) << 8 ) | (* (src + i ) >> 8 );
391
428
392
429
// copy_16bpp(src + i, dst + j);
@@ -396,13 +433,14 @@ void rotate_16bpp_swap(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_data_t *
396
433
397
434
// MIRROR_X MIRROR_Y
398
435
case LCD_ROTATION_180 :
399
- LCD_UNUSED ( j ) ;
436
+ j = dst_width - 1 - x_start ;
400
437
LCD_UNUSED (src_bytes_per_line );
401
438
LCD_UNUSED (offset );
439
+ dst_height -= 1 ;
402
440
403
441
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
404
- i = (dst_height - 1 - y ) * dst_width + ( dst_width - 1 - x_start ) ;
405
- for (uint32_t x = x_start ; x < x_end ; x ++ ) {
442
+ i = (( dst_height - y ) * dst_width ) + j ;
443
+ for (uint32_t x = x_start ; x < x_end ; x ++ ) {
406
444
* (dst + i ) = (* src << 8 ) | (* src >> 8 );
407
445
408
446
// copy_16bpp(src, dst + i);
@@ -414,11 +452,16 @@ void rotate_16bpp_swap(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_data_t *
414
452
415
453
// SWAP_XY MIRROR_X
416
454
case LCD_ROTATION_270 :
455
+ uint32_t m ;
456
+ uint32_t o ;
457
+
417
458
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
459
+ m = (y * src_bytes_per_line ) - offset ;
460
+ o = dst_width - 1 - y ;
461
+
418
462
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
419
- i = y * src_bytes_per_line + x - offset ;
420
- j = (x * dst_width + dst_width - 1 - y );
421
-
463
+ i = m + x ;
464
+ j = (x * dst_width ) + o ;
422
465
* (dst + j ) = (* (src + i ) << 8 ) | (* (src + i ) >> 8 );
423
466
424
467
// copy_16bpp(src + i, dst + j);
@@ -469,24 +512,29 @@ void rotate_16bpp(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_data_t *copy_
469
512
break ;
470
513
471
514
case LCD_ROTATION_90 :
515
+ uint32_t src_line_bytes ;
516
+ dst_height -= 1 ;
517
+
472
518
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
473
- for (uint32_t x = x_start ; x < x_end ; x ++ ) {
474
- i = y * src_bytes_per_line + x - offset ;
475
- j = (dst_height - 1 - x ) * dst_width + y ;
519
+ src_line_bytes = (y * src_bytes_per_line ) - offset ;
476
520
521
+ for (uint32_t x = x_start ; x < x_end ; x ++ ) {
522
+ i = src_line_bytes + x ;
523
+ j = ((dst_height - x ) * dst_width ) + y ;
477
524
copy_16bpp (src + i , dst + j );
478
525
}
479
526
}
480
527
break ;
481
528
482
529
// MIRROR_X MIRROR_Y
483
530
case LCD_ROTATION_180 :
484
- LCD_UNUSED ( j ) ;
531
+ j = dst_width - 1 - x_start ;
485
532
LCD_UNUSED (src_bytes_per_line );
486
533
LCD_UNUSED (offset );
534
+ dst_height -= 1 ;
487
535
488
536
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
489
- i = (dst_height - 1 - y ) * dst_width + ( dst_width - 1 - x_start ) ;
537
+ i = (( dst_height - y ) * dst_width ) + j ;
490
538
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
491
539
copy_16bpp (src , dst + i );
492
540
src ++ ;
@@ -497,11 +545,16 @@ void rotate_16bpp(uint16_t *src, uint16_t *dst, mp_lcd_sw_rotation_data_t *copy_
497
545
498
546
// SWAP_XY MIRROR_X
499
547
case LCD_ROTATION_270 :
548
+ uint32_t m ;
549
+ uint32_t o ;
550
+
500
551
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
501
- for (uint32_t x = x_start ; x < x_end ; x ++ ) {
502
- i = y * src_bytes_per_line + x - offset ;
503
- j = (x * dst_width + dst_width - 1 - y );
552
+ m = (y * src_bytes_per_line ) - offset ;
553
+ o = dst_width - 1 - y ;
504
554
555
+ for (uint32_t x = x_start ; x < x_end ; x ++ ) {
556
+ i = m + x ;
557
+ j = (x * dst_width ) + o ;
505
558
copy_16bpp (src + i , dst + j );
506
559
}
507
560
}
@@ -535,24 +588,29 @@ void rotate_24bpp(uint8_t *src, uint8_t *dst, mp_lcd_sw_rotation_data_t *copy_da
535
588
536
589
switch (copy_data -> rotation ) {
537
590
case LCD_ROTATION_90 :
591
+ uint32_t src_line_bytes ;
592
+ dst_height -= 1 ;
593
+
538
594
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
539
- for (uint32_t x = x_start ; x < x_end ; x ++ ) {
540
- i = y * src_bytes_per_line + x * 3 - offset ;
541
- j = ((dst_height - 1 - x ) * dst_width + y ) * 3 ;
595
+ src_line_bytes = (y * src_bytes_per_line ) - offset ;
542
596
597
+ for (uint32_t x = x_start ; x < x_end ; x ++ ) {
598
+ i = src_line_bytes + (x * 3 );
599
+ j = (((dst_height - x ) * dst_width ) + y ) * 3 ;
543
600
copy_24bpp (src + i , dst + j );
544
601
}
545
602
}
546
603
break ;
547
604
548
605
// MIRROR_X MIRROR_Y
549
606
case LCD_ROTATION_180 :
550
- LCD_UNUSED ( j ) ;
607
+ j = dst_width - 1 - x_start ;
551
608
LCD_UNUSED (src_bytes_per_line );
552
609
LCD_UNUSED (offset );
610
+ dst_height -= 1 ;
553
611
554
612
for (int y = y_start ; y < y_end ; y ++ ) {
555
- i = ((dst_height - 1 - y ) * dst_width + ( dst_width - 1 - x_start ) ) * 3 ;
613
+ i = ((( dst_height - y ) * dst_width ) + j ) * 3 ;
556
614
for (size_t x = x_start ; x < x_end ; x ++ ) {
557
615
copy_24bpp (src , dst + i );
558
616
src += 3 ;
@@ -563,11 +621,16 @@ void rotate_24bpp(uint8_t *src, uint8_t *dst, mp_lcd_sw_rotation_data_t *copy_da
563
621
564
622
// SWAP_XY MIRROR_X
565
623
case LCD_ROTATION_270 :
624
+ uint32_t m ;
625
+ uint32_t o ;
626
+
566
627
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
567
- for (uint32_t x = x_start ; x < x_end ; x ++ ) {
568
- i = y * src_bytes_per_line + x * 3 - offset ;
569
- j = (x * dst_width + dst_width - 1 - y ) * 3 ;
628
+ m = (y * src_bytes_per_line ) - offset ;
629
+ o = dst_width - 1 - y ;
570
630
631
+ for (uint32_t x = x_start ; x < x_end ; x ++ ) {
632
+ i = m + (x * 3 );
633
+ j = ((x * dst_width ) + o ) * 3 ;
571
634
copy_24bpp (src + i , dst + j );
572
635
}
573
636
}
@@ -601,24 +664,30 @@ void rotate_32bpp(uint32_t *src, uint32_t *dst, mp_lcd_sw_rotation_data_t *copy_
601
664
602
665
switch (copy_data -> rotation ) {
603
666
case LCD_ROTATION_90 :
667
+ uint32_t src_line_bytes ;
668
+ dst_height -= 1 ;
669
+
604
670
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
605
- for (uint32_t x = x_start ; x < x_end ; x ++ ) {
606
- i = y * src_bytes_per_line + x - offset ;
607
- j = (dst_height - 1 - x ) * dst_width + y ;
671
+ src_line_bytes = (y * src_bytes_per_line ) - offset ;
608
672
673
+ for (uint32_t x = x_start ; x < x_end ; x ++ ) {
674
+ i = src_line_bytes + x ;
675
+ j = ((dst_height - x ) * dst_width ) + y ;
609
676
copy_32bpp (src + i , dst + j );
610
677
}
611
678
}
612
679
break ;
613
680
614
681
// MIRROR_X MIRROR_Y
615
682
case LCD_ROTATION_180 :
616
- LCD_UNUSED ( j ) ;
683
+ j = dst_width - 1 - x_start ;
617
684
LCD_UNUSED (src_bytes_per_line );
618
685
LCD_UNUSED (offset );
686
+ dst_height -= 1 ;
619
687
620
688
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
621
- i = (dst_height - 1 - y ) * dst_width + (dst_width - 1 - x_start );
689
+ i = ((dst_height - y ) * dst_width ) + j ;
690
+
622
691
for (uint32_t x = x_start ; x < x_end ; x ++ ) {
623
692
copy_32bpp (src , dst + i );
624
693
src ++ ;
@@ -629,11 +698,16 @@ void rotate_32bpp(uint32_t *src, uint32_t *dst, mp_lcd_sw_rotation_data_t *copy_
629
698
630
699
// SWAP_XY MIRROR_X
631
700
case LCD_ROTATION_270 :
701
+ uint32_t m ;
702
+ uint32_t o ;
703
+
632
704
for (uint32_t y = y_start ; y < y_end ; y ++ ) {
633
- for (uint32_t x = x_start ; x < x_end ; x ++ ) {
634
- i = y * src_bytes_per_line + x - offset ;
635
- j = x * dst_width + dst_width - 1 - y ;
705
+ m = (y * src_bytes_per_line ) - offset ;
706
+ o = dst_width - 1 - y ;
636
707
708
+ for (uint32_t x = x_start ; x < x_end ; x ++ ) {
709
+ i = m + x ;
710
+ j = (x * dst_width ) + o ;
637
711
copy_32bpp (src + i , dst + j );
638
712
}
639
713
}
0 commit comments