GDIPlus的Pen的一个小Bug

首先是MSDN里面Pen的SetTransform Method的说明

Pen::SetTransform Method


The SetTransform method sets the world transformation of this Pen object.

Syntax

Status SetTransform(      

    const Matrix *matrix
);

Parameters

matrix
[in] Pointer to a Matrix object that specifies the world transformation.

Return Value

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

附MSDN上面的使用例子:

VOID Example_SetTransform(HDC hdc)
{
Graphics graphics(hdc);

Matrix matrix(20, 0, 0, 10, 0, 0); // scale

// Create a pen, and use it to draw a rectangle.
Pen pen(Color(255, 0, 0, 255), 2);
graphics.DrawRectangle(&pen, 10, 50, 150, 100);

// Scale the pen width by a factor of 20 in the horizontal
// direction and a factor of 10 in the vertical direction.
pen.SetTransform(&matrix);

// Draw a rectangle with the transformed pen.
graphics.DrawRectangle(&pen, 200, 50, 150, 100);
}

这里没有说明的是:
Pen pen(Color(255, 0, 0, 255), 2);
这里设置的线宽小于等于1.5时,则后面设置的坐标变换将不起作用,画出的线宽会变为1。
此外如果在设置坐标变换后,在某个方向的变换后线宽如果小于1,则也会失效,具体如下:
Pen pen(Color(255, 255, 0, 0), 2);
Matrix ctmBase(10, 0, 0, 0.5, 0, 100);
pen.SetTransform(&ctmBase);
GraphicsPath Path;
Path.AddLine(100, 300, 300, 300);
Path.AddLine(100, 300, 100, 600);
graphics.DrawPath(&pen, &Path);
你会发现两条线都为1线宽,只要把0.5增加一点,坐标变换就会正确作用了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值