zoukankan      html  css  js  c++  java
  • 文字旋转

    VC中文字旋转实现方式:

    1、不使用Graphics,直接用CDC绘制

    方法:编辑字体,然后DC选中这个字体,即可实现

    具体:

    	CFont* pFont = pDC->GetCurrentFont();
    	LOGFONT logFont ;
    	pFont->GetLogFont(&logFont);	
    	logFont.lfEscapement = 600;//900/10 = 90
    	wcscpy(logFont.lfFaceName,L"楷体_GB2312");
    	HFONT hFont = CreateFontIndirect(&logFont); 
    	pDC->SelectObject(hFont);
    	pDC->TextOut(200,200,L"VC中如何把一串文字旋转90度显示的?");
    

    这里需要注意的地方:LOGFONT结构中有两个内容需要设置 

    lfEscapement 为旋转的角度,以1/10度为单位
    lfFaceName 为字体名称,用系统默认的@System字体是不能实现旋转的,这里选择了楷体,宋体也可以

    2、使用Graphics类

    这个类提供了TranslateTransform、RotateTransform实现坐标系的平移及旋转

    下面的代码实现了以(200,200)为原点旋转 30度的操作

    	graphic.TranslateTransform(200,200);
    	graphic.RotateTransform(360 - 30);
    
    	graphic.DrawString(str, str.GetLength(),
    		&myFont, PointF(0,0), NULL, &blackBrush);
    
    	graphic.RotateTransform(30 - 360);
    	graphic.TranslateTransform(-200,-200);
    

    记得在绘制结束后把旋转恢复,不然之后的绘制都带着平移跟旋转




  • 相关阅读:
    tilestache
    VBoxManage翕令
    曲线平滑算法
    Python获取当前路径
    ebook
    设定linux为多用户模式
    NodeJS配置TaoBao源
    ArcGIS 中取出面上最大的Z值的坐标点
    降水量分级
    R中的空间数据分析
  • 原文地址:https://www.cnblogs.com/luleigreat/p/2640274.html
Copyright © 2011-2022 走看看