首先定义了一个宏PATTERN_BITMAP: #define PATTERN_BITMAP(pattern_array, width, row, col) \ (((*((uint8_t *)pattern_array + width * row + col/8)) & (1 << (7-(col%8)))) >> (7-(col%8))) 其中width的值是固定的32 要求: 1.将位图逆时针旋转90度 2.行数和列数不能变,将多余的列按顺序拼接到列的后面
时间: 2024-02-09 15:11:03 浏览: 66
根据题目要求,将指定的位图逆时针旋转90度,并将多余的列按顺序拼接到列的后面,可以使用如下宏:
```
#define PATTERN_BITMAP_ROTATE90(pattern_array, width, height) \
for (int i = 0; i < width / 2; i++) { \
for (int j = i; j < height - i - 1; j++) { \
uint8_t temp = PATTERN_BITMAP(pattern_array, 32, i, j); \
*((uint8_t *)pattern_array + 32 * i + j/8) &= ~(1 << (7-(j%8))); \
*((uint8_t *)pattern_array + 32 * i + j/8) |= (PATTERN_BITMAP(pattern_array, 32, j, width - i - 1) << (7-(j%8))); \
*((uint8_t *)pattern_array + 32 * j + (width - i - 1)/8) &= ~(1 << (7-((width - i - 1)%8))); \
*((uint8_t *)pattern_array + 32 * j + (width - i - 1)/8) |= (PATTERN_BITMAP(pattern_array, 32, width - i - 1, width - j - 1) << (7-((width - i - 1)%8))); \
*((uint8_t *)pattern_array + 32 * (width - i - 1) + (width - j - 1)/8) &= ~(1 << (7-((width - j - 1)%8))); \
*((uint8_t *)pattern_array + 32 * (width - i - 1) + (width - j - 1)/8) |= (PATTERN_BITMAP(pattern_array, 32, width - j - 1, i) << (7-((width - j - 1)%8))); \
*((uint8_t *)pattern_array + 32 * (width - j - 1) + i/8) &= ~(1 << (7-(i%8))); \
*((uint8_t *)pattern_array + 32 * (width - j - 1) + i/8) |= (temp << (7-(i%8))); \
} \
} \
if (width % 2 != 0) { \
int mid = width / 2; \
for (int i = 0; i < height / 2; i++) { \
uint8_t temp = PATTERN_BITMAP(pattern_array, 32, mid, i); \
*((uint8_t *)pattern_array + 32 * mid + i/8) &= ~(1 << (7-(i%8))); \
*((uint8_t *)pattern_array + 32 * mid + i/8) |= (PATTERN_BITMAP(pattern_array, 32, height - i - 1, mid) << (7-(i%8))); \
*((uint8_t *)pattern_array + 32 * (height - i - 1) + mid/8) &= ~(1 << (7-(mid%8))); \
*((uint8_t *)pattern_array + 32 * (height - i - 1) + mid/8) |= (PATTERN_BITMAP(pattern_array, 32, mid, i) << (7-(mid%8))); \
} \
for (int i = mid+1; i < width - mid - 1; i++) { \
for (int j = 0; j < height / 2; j++) { \
uint8_t temp = PATTERN_BITMAP(pattern_array, 32, i, j); \
*((uint8_t *)pattern_array + 32 * i + j/8) &= ~(1 << (7-(j%8))); \
*((uint8_t *)pattern_array +
阅读全文