MFC/GDI CRgn CreateEllipticRgn 少了两个像素?
MFC/GDI CRgn CreateEllipticRgn is two pixels short?
如果我这样做 CRgn::CreateEllipticRgn(0, 0, 120, 120);
结果会在右侧和底部短两个像素。这是为什么?我想也许是因为一个区域在轮廓内而不是在轮廓上,但在那种情况下,它应该是围绕整个圆圈的 1 个像素边界,而不是在右侧和底部关闭 2 个像素。有什么想法吗?
TIA!!
用图片说明问题:
//RECT
hPen = CreatePen(PS_SOLID, 1, RGB(255, 100, 0));
SelectObject(hdc, hPen);
Rectangle(hdc, 10, 10, 130, 130);
//Ellipse
hBrush = CreateSolidBrush(RGB(255, 0, 0));
HRGN hTemp = CreateEllipticRgn(10, 10, 130, 130);
FrameRgn(hdc, hTemp, hBrush, 1, 1);
来自Rectangle function,指出:
The rectangle that is drawn excludes the bottom and right edges.
If a PS_NULL pen is used, the dimensions of the rectangle are 1 pixel
less in height and 1 pixel less in width.
来自CreateEllipticRgn,指出:
A bounding rectangle defines the size, shape, and orientation of the
region: The long sides of the rectangle define the length of the
ellipse's major axis; the short sides define the length of the
ellipse's minor axis; and the center of the rectangle defines the
intersection of the major and minor axes.
从测试结果来看,椭圆的长宽不包括底边和右边。
如果我这样做 CRgn::CreateEllipticRgn(0, 0, 120, 120);
结果会在右侧和底部短两个像素。这是为什么?我想也许是因为一个区域在轮廓内而不是在轮廓上,但在那种情况下,它应该是围绕整个圆圈的 1 个像素边界,而不是在右侧和底部关闭 2 个像素。有什么想法吗?
TIA!!
用图片说明问题:
//RECT
hPen = CreatePen(PS_SOLID, 1, RGB(255, 100, 0));
SelectObject(hdc, hPen);
Rectangle(hdc, 10, 10, 130, 130);
//Ellipse
hBrush = CreateSolidBrush(RGB(255, 0, 0));
HRGN hTemp = CreateEllipticRgn(10, 10, 130, 130);
FrameRgn(hdc, hTemp, hBrush, 1, 1);
来自Rectangle function,指出:
The rectangle that is drawn excludes the bottom and right edges.
If a PS_NULL pen is used, the dimensions of the rectangle are 1 pixel less in height and 1 pixel less in width.
来自CreateEllipticRgn,指出:
A bounding rectangle defines the size, shape, and orientation of the region: The long sides of the rectangle define the length of the ellipse's major axis; the short sides define the length of the ellipse's minor axis; and the center of the rectangle defines the intersection of the major and minor axes.
从测试结果来看,椭圆的长宽不包括底边和右边。