我从这里获取了公式: https: //ru.wikipedia.org/wiki/Rotation_matrix 我正在尝试旋转图片,但我得到了白点,我玩了符号,但它没有帮助。这里:https: //ru.stackoverflow.com/questions/1063702/Recalculation-of-coordinates-when-rotating-an-image我读到了关于坐标计数的内容,我没有考虑到计数是从顶部开始的- 左角。这可能是一个四舍五入的问题,但对其进行操作并没有产生结果。需要改变什么?
int* Plane1 = new int[256 * 100 * 3];
int Angle = 20;
int main()
{
readBMPTo1dArray("Helicopter.bmp", Plane1, 256, 100);
int red = 0;
int green = 0;
int blue = 0;
while (true)
{
HWND hwnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_LAYERED, L"STATIC", NULL, WS_VISIBLE | WS_POPUP, 0, 0, 1000, 1000, NULL, NULL, NULL, NULL);
SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 0, LWA_COLORKEY);
HDC hdc = GetDC(hwnd);
UpdateWindow(hwnd);
Angle = Angle + 1;
if (Angle >= 360)
{
Angle = 0;
}
UpdateWindow(hwnd);
for (int y = 0; y < 100; y++)
{
for (int x = 0; x < 256; x++)
{
red = (Plane1[y * 256 * 3 + x * 3 + 0] + 256) % 256;
green = (Plane1[y * 256 * 3 + x * 3 + 1] + 256) % 256;
blue = (Plane1[y * 256 * 3 + x * 3 + 2] + 256) % 256;
COLORREF color = RGB(red, green, blue);
int x1 = x * cos(Angle * M_PI / 180) - y * sin(Angle * M_PI / 180);
int y1 = x * sin(Angle * M_PI / 180) + y * cos(Angle * M_PI / 180);
SetPixel(hdc, x1 + 500, y1 + 500, color);
}
}
Sleep(1000);
UpdateWindow(hwnd);
}
}



使用逆变换,即 对于每个结果点 (r),查找相应的源图像点 (s)。
绕中心旋转的伪代码: