请让宏PATTERN_BITMAP_ROTATE90的参数和宏保持一致
时间: 2023-08-04 16:08:18 浏览: 82
Bitmap_transform.rar_Bitmap Transform_bitmap
好的,根据您的要求,将宏PATTERN_BITMAP_ROTATE90的定义修改为如下形式:
```
#define PATTERN_BITMAP_ROTATE90(pattern_array, width) \
do { \
for (int i = 0; i < (width) / 8 / 2; i++) { \
for (int j = i * 16; j < (width) - i * 16 - 16; j += 16) { \
uint8_t temp = 0; \
for (int k = 0; k < 8; k++) { \
temp |= (PATTERN_BITMAP(pattern_array, width, i * 2 + k % 2, j + k / 2) << (7 - k)); \
} \
for (int k = 0; k < 8; k++) { \
*((uint8_t *)(pattern_array) + (width) * (i * 2 + k % 2) + j / 8 + k / 2) &= ~(1 << (7 - (j % 8 + k / 2))); \
*((uint8_t *)(pattern_array) + (width) * (i * 2 + k % 2) + j / 8 + k / 2) |= ((temp >> (7 - k)) & 0x01) << (7 - (j % 8 + k / 2)); \
} \
temp = 0; \
for (int k = 0; k < 8; k++) { \
temp |= (PATTERN_BITMAP(pattern_array, width, i * 2 + k % 2, j + 8 + k / 2) << (7 - k)); \
} \
for (int k = 0; k < 8; k++) { \
*((uint8_t *)(pattern_array) + (width) * (i * 2 + k % 2) + (j + 8) / 8 + k / 2) &= ~(1 << (7 - ((j + 8) % 8 + k / 2))); \
*((uint8_t *)(pattern_array) + (width) * (i * 2 + k % 2) + (j + 8) / 8 + k / 2) |= ((temp >> (7 - k)) & 0x01) << (7 - ((j + 8) % 8 + k / 2)); \
} \
} \
} \
} while (0)
```
这个宏的实现基本上和之前的宏一致,只是将旋转的高度改为了宏定义的width的1/2,以保持参数和宏定义的一致性。此外,为了增加代码的可读性,将for循环改为do-while循环,并在最后添加了一个空的while(0)语句,以防止宏的错误使用。
阅读全文