3
3
__inline xy rotate (int t , int x , int y , int w , int h ) {
4
4
xy p = {x , y };
5
5
switch (t ) {
6
+ // 90° CCW or 270° CW
6
7
case A90 :
7
- p .x = r90_x ( x , y , w , h ) ;
8
- p .y = r90_y ( x , y , w , h ) ;
8
+ p .x = y ;
9
+ p .y = w - 1 - x ;
9
10
break ;
11
+ // 180° CCW
10
12
case A180 :
11
- p .x = r180_x ( x , y , w , h ) ;
12
- p .y = r180_y ( x , y , w , h ) ;
13
+ p .x = w - 1 - x ;
14
+ p .y = h - 1 - y ;
13
15
break ;
16
+ // 270° CCW or 90° CW
14
17
case A270 :
15
- p .x = r270_x ( x , y , w , h ) ;
16
- p .y = r270_y ( x , y , w , h ) ;
18
+ p .x = h - 1 - y ;
19
+ p .y = x ;
17
20
break ;
21
+ // flip Y
18
22
case F180 :
19
- p .x = fy180_x ( x , y , w , h ) ;
20
- p .y = fy180_y ( x , y , w , h ) ;
23
+ // p.x = x ;
24
+ p .y = h - 1 - y ;
21
25
break ;
22
26
}
23
27
return p ;
@@ -28,20 +32,20 @@ __inline uint32_t _565(uint32_t x) {
28
32
}
29
33
30
34
__inline uint32_t _8888rev (uint32_t px ) {
31
- return (((px >> 16 ) & 0xff ) | (px & 0xff00 ) | ((px << 16 ) & 0xff0000 )); // | 0xff000000)
35
+ return (((px >> 16 ) & 0xff ) | (px & 0xff00 ) | ((px << 16 ) & 0xff0000 )); // | 0xff000000
32
36
}
33
37
34
- void RGBA (int pix , uint32_t * __restrict dst , void * __restrict source , int y , int h , int w , int hh , int dw , int pad , int rot ) {
38
+ void RGBA (int pix , uint32_t * __restrict dst , const void * __restrict source , int y , int h , int w , int hh , int dw , int pad , int rot ) {
35
39
int x ;
36
40
xy rxy ;
37
- uint16_t * src16 ;
38
- uint32_t * src32 ;
41
+ const uint16_t * src16 ;
42
+ const uint32_t * src32 ;
39
43
40
44
switch (pix ) {
41
45
//case BIT_SHORT5551:
42
46
// break;
43
47
case BIT_INT_8888REV :
44
- src32 = (uint32_t * )source ;
48
+ src32 = (const uint32_t * )source ;
45
49
int pad32 = pad >> 2 ;
46
50
if (rot == NO_ROT ) {
47
51
for (; y < h ; ++ y ) {
@@ -54,14 +58,14 @@ void RGBA(int pix, uint32_t *__restrict dst, void *__restrict source, int y, int
54
58
for (; y < h ; ++ y ) {
55
59
for (x = 0 ; x < w ; ++ x ) {
56
60
rxy = rotate (rot , x , y , w , hh );
57
- dst [rxy .x + rxy .y * w ] = _8888rev (* src32 ++ );
61
+ dst [rxy .x + rxy .y * dw ] = _8888rev (* src32 ++ );
58
62
}
59
63
src32 += pad32 ;
60
64
}
61
65
}
62
66
break ;
63
67
case BIT_SHORT565 :
64
- src16 = (uint16_t * )source ;
68
+ src16 = (const uint16_t * )source ;
65
69
int pad16 = pad >> 1 ;
66
70
if (rot == NO_ROT ) {
67
71
for (; y < h ; ++ y ) {
0 commit comments