使用soui4实现镜像绘制

void ContainerBox::OnPaint(IRenderTarget* pRT)
{
	CRect rcClient = GetClientRect();
	CPoint ptCenter = rcClient.CenterPoint();
	
	SStringW sstrFontFormat = L"face:宋体,bold:0,italic:0,underline:0,strike:0,size:30";
	SOUI::IFontPtr pFont = SFontPool::GetFont(sstrFontFormat, GetScale());
	pRT->SelectObject(pFont);
	
	//测试镜像
	CRect rcTemp;
	rcTemp.left = ptCenter.x - 100;
	rcTemp.right = ptCenter.x + 100;
	rcTemp.top = ptCenter.y - 50;
	rcTemp.bottom = ptCenter.y + 50;

    SStringW sstrTxt = L"1234567890A";
    {//原始数据
            {//绘制个背景色便于观察
                    COLORREF clrBkgnd = GETCOLOR(L"RGB(0,255,0)");
                    CAutoRefPtr<IBrush> brush, oldbrush;
                    pRT->CreateSolidColorBrush(clrBkgnd, &brush);
                    pRT->SelectObject(brush, (IRenderObj**)&oldbrush);
                    pRT->FillRectangle(&rcTemp);
                    pRT->SelectObject(oldbrush, NULL);
            }
            pRT->DrawText(sstrTxt, -1, (LPRECT)rcTemp, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    }

    {//左镜像
            CRect rcMirror(rcTemp);
            rcMirror.left = rcTemp.right;
            rcMirror.right = rcMirror.left + rcTemp.Width();

            SMatrix matrix;
            matrix.setScale2(-1, 1, ptCenter.x, ptCenter.y);
            pRT->SetTransform(matrix.fMat, NULL);
            pRT->DrawText(sstrTxt, -1, (LPRECT)rcMirror, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
            pRT->SetTransform(SMatrix().fMat, NULL);
    }

    {//右镜像
            CRect rcMirror(rcTemp);
            rcMirror.left = rcTemp.left - rcTemp.Width();
            rcMirror.right = rcTemp.left;

            SMatrix matrix;
            matrix.setScale2(-1, 1, ptCenter.x, ptCenter.y);
            pRT->SetTransform(matrix.fMat, NULL);
            pRT->DrawText(sstrTxt, -1, (LPRECT)rcMirror, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
            pRT->SetTransform(SMatrix().fMat, NULL);
    }

    {//上镜像
            CRect rcMirror(rcTemp);
            rcMirror.top = rcTemp.bottom;
            rcMirror.bottom = rcMirror.top + rcTemp.Height();

            SMatrix matrix;
            matrix.setScale2(1, -1, ptCenter.x, ptCenter.y);
            pRT->SetTransform(matrix.fMat, NULL);
            pRT->DrawText(sstrTxt, -1, (LPRECT)rcMirror, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
            pRT->SetTransform(SMatrix().fMat, NULL);
    }

    {//下镜像
            CRect rcMirror(rcTemp);
            rcMirror.bottom = rcTemp.top;
            rcMirror.top = rcTemp.top - rcTemp.Height();

            SMatrix matrix;
            matrix.setScale2(1, -1, ptCenter.x, ptCenter.y);
            pRT->SetTransform(matrix.fMat, NULL);
            pRT->DrawText(sstrTxt, -1, (LPRECT)rcMirror, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
            pRT->SetTransform(SMatrix().fMat, NULL);
    }
}

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值