void CShowWnd::Rotate(CDC *pDC, int degrees, CRect bounds) { CPoint origin(bounds.left + bounds.Width()/2, bounds.top + bounds.Height()/2); double dRadians = degrees / 180.00 * 3.14159265358979; // Go through the final rows and columns, filling in the data int stepx = 0, stepy = 0; for (int cols = bounds.left; cols < bounds.right; cols++) { for (int rows = bounds.top; rows < bounds.bottom; rows++) { POINT before; POINT after; after.x = cols; after.y = rows; // Calculate the original x and y int x1 = Round((after.x-origin.x) * cos(dRadians) - (after.y-origin.y) * sin(dRadians) + origin.x); int y1 = Round((after.y-origin.y) * cos(dRadians) + (after.x-origin.x) * sin(dRadians) + origin.y);
{
CPoint origin(bounds.left + bounds.Width()/2, bounds.top + bounds.Height()/2);
double dRadians = degrees / 180.00 * 3.14159265358979; // Go through the final rows and columns, filling in the data
int stepx = 0, stepy = 0;
for (int cols = bounds.left; cols < bounds.right; cols++)
{
for (int rows = bounds.top; rows < bounds.bottom; rows++)
{
POINT before;
POINT after; after.x = cols;
after.y = rows; // Calculate the original x and y
int x1 = Round((after.x-origin.x) * cos(dRadians) - (after.y-origin.y) * sin(dRadians) + origin.x);
int y1 = Round((after.y-origin.y) * cos(dRadians) + (after.x-origin.x) * sin(dRadians) + origin.y);
// 平移
x1 += 34;
y1 += 34; before.x = x1;
before.y = y1; if (wall_buf[cols][rows] == '1')
pDC->SetPixel(before, RGB(57, 109, 165));
else if (wall_buf[cols][rows] == '2')
pDC->SetPixel(before, RGB(255, 0, 0));
else if (wall_buf[cols][rows] == '3')
pDC->SetPixel(before, RGB(0, 0, 0));
}
}
}旋转后这个矩形每一行都会间隔出现空点
大哥图片发不上来太郁闷了哎
弄不好我晕死
能留email或msn,qq吗?