Direct2D DirectWrite绘制文字
来源:互联网 发布:中国文化软实力 知乎 编辑:程序博客网 时间:2024/05/16 12:00
绘制文本使用DirectWrite:
为了简化 DirectWrite 的使用,RenderTarget有3个方法可以直接绘制文本:
- DrawText,用于简单绘制,支持Unicode。
- DrawTextLayout ,提供布局和格式。
- DrawGlyphRun,精确控制字形级别布局。
写一个简单的例子:
别忘了头文件和lib
#include "wincodec.h"
dwrite.lib;
下面的是d2d必须的
d2d1.lib;
dxgi.lib;
dxguid.lib;
创建文本的流程如下:
类似于,还是需要一个Factory,只不过这次是:
- IDWriteFactory。然后初始化。
- 然后创建文本格式,包括字体,字号等。
- 设置绘制布局。
- 绘制。
pRenderTarget->BeginDraw();IDWriteFactory* pDWriteFactory = NULL;IDWriteTextFormat* pTextFormat = NULL;// create dwrite factoryDWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,__uuidof(IDWriteFactory),reinterpret_cast<IUnknown**>(&pDWriteFactory));//create text formathr = pDWriteFactory->CreateTextFormat(L"Arial", NULL,DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 20.0f * 96.0f/72.0f, L"en-US", &pTextFormat);D2D1_RECT_F layoutRect = D2D1::RectF(1000.f, 1000.f, 200.f, 200.f);//draw textpRenderTarget->DrawText(L"Hello D2D",wcslen(L"Hello D2D"),pTextFormat,layoutRect, pBlackBrush);pRenderTarget->EndDraw();
http://msdn.microsoft.com/zh-CN/library/windows/apps/dd371554
- Direct2D DirectWrite绘制文字
- Direct2D中的DirectWrite
- WTL-Direct2D,DirectWrite,Windows Animation
- Direct2D中DirectWrite处理WM_SIZE消息
- Direct2D 几何图形绘制基础
- Direct2D WIC绘制图片
- Direct2D中DWrite文字
- Direct2d绘制图片的问题
- Direct2d绘制图片的问题
- Direct2D绘制的MFC控件
- Direct2D绘制的MFC控件
- Direct2D教程(十)绘制文本
- 绘制文字
- 文字绘制
- 绘制文字
- 绘制文字
- 绘制文字
- 绘制文字
- hdu 1711
- 黑马程序员_集合1_(ArrayList、LinkedList、Vector、Iterator、ListIterator)
- Direct2D WIC绘制图片
- Struts2.x+JFreeChart搭建框架出错(五)
- 程序员——伤不起的三十岁
- Direct2D DirectWrite绘制文字
- uva 10420 List of Conquests(检索+排序)
- Google hacker的入侵方法
- 在Android项目中使用 OpenCV 入门
- hust 1010 最短循环节
- TranslateAnimation详解
- pygame.event.get()
- ubuntu+nginx安装配置应用说明
- Weka学习实验总结