GDI+ 文字旋转后 位置变化.

来源:互联网 发布:linux 服务器版 编辑:程序博客网 时间:2024/05/16 01:10

StringFormat format;
  format.SetAlignment(StringAlignmentCenter);  
  format.SetLineAlignment(StringAlignmentNear);
  Gdiplus::Font clrFont(L"Arial",65,FontStyleRegular,UnitPixel );
  SolidBrush blackBrush(Color(255, 0, 0, 0));

  RectF rcText(PointF(rcBounds.left-m_fSideWidth*cxInch*0.9,rcBounds.top+nw+txtSize/2),SizeF(txtSize,txtSize)); 
  PointF txtPoint[4]={
    PointF(rcText.GetLeft(),rcText.GetTop()),
    PointF(rcText.GetRight(),rcText.GetTop()),
    PointF(rcText.GetLeft(),rcText.GetBottom()),
    PointF(rcText.GetRight(),rcText.GetBottom())
  };
    graph.RotateTransform(REAL(-90)); // 旋转    角度
  graph.TransformPoints(CoordinateSpaceWorld,CoordinateSpacePage,txtPoint,4);//求旋转后的位置
  RectF rcTrText(txtPoint[0],SizeF(txtSize,txtSize)); 
  graph.DrawString(IntToStr(nw/cxInch),-1,&clrFont,rcTrText,&format,&blackBrush);     
  graph.ResetTransform();

0 0
原创粉丝点击