【发布时间】:2014-10-05 13:47:36
【问题描述】:
使用 Windows 图像组件 (WIC),我想为我的 Windows 桌面应用程序执行以下操作(Direct2D/C++ with Windows 7 SP1 - Visual Studio 2013)
选择任何类型的 RenderTarget(Direct2D Hwnd/Bitmap/WICBitmap - 等)用于绘图
创建一个空位图(D2D1Bitmap 或 IWICBitmap - 以适用者为准)
开始绘制 - 填充颜色,绘制一些线条和椭圆 - 结束绘制 ==>(全部在位图中)
在某个时间点,我需要 将位图中绘制的内容作为图像保存在我的电脑中
将位图放置在 x1,y1(左上角 - xy 坐标)和 x2,y2 (右下角 - xy 坐标)渲染目标。因为 窗口的其余空间将由工具栏使用。
如何使用 C++/Direct2D 实现这一点?
我的功能的 GDI+ 代码:
Bitmap* pBmp = NULL; //create null or empty bitmap
Graphics* pGrBuf = NULL; //initialise graphics to null
pBmp = new Bitmap((INT)rectClient.Width, (INT)rectClient.Height);
pGrBuf = new Graphics(pBmp);
在这个图形上,我总是可以画线、矩形等。
pGrBuf.DrawRectangle(....)
pGrBuf.DrawLine(...)
最后,为了达到第 5 点
//leave some space (30, 30 in xy co-ordinates) for putting the toolbox in the top
pGrBuf.DrawImage(m_pBmp, 30.0f, 30.0f);
特意省略了第 4 点的代码。
【问题讨论】:
标签: c++ windows graphics bitmap direct2d