原文参考:
https://quantum6.blog.csdn.net/article/details/110794038
在使用过程中,吾发现旋转代码很难理解。如果原来数据有特殊要求,这样是有问题的。于是经过一番实验(列出了一个数组,然后手工旋转,对照算法),找到了新的公式:
static void rotate_90(FT_Bitmap* pBmp)
{
int w = pBmp->width;
int h = pBmp->rows;
int i=0;
char* pRotated;
int size;
int offset=0;
size = w * h;
pRotated = (char*)malloc(size);
memcpy(pRotated, pBmp->buffer, size);
for (int y=0; ybuffer[(h-y-1)*w+x];
}
}
dumpBuffer(pRotated, h, w);
}
static void rotate_270(FT_Bitmap* pBmp)
{
int w = pBmp->width;
int h = pBmp->rows;
int i=0;
char* pRotated;
int size;
int offset=0;
size = w * h;
pRotated = (char*)malloc(size);
memcpy(pRotated, pBmp->buffer, size);
for (int y=0; ybuffer[y*w+x];
}
}
dumpBuffer(pRotated, h, w);
}