DirectX Surface到打印机 [英] DirectX Surface to Printer
问题描述
您好,
我创建了一个3D引擎,我可以从ID3D11ShaderResourceView1中提取ID2D1RenderTarget。基本上,我可以从3D对象中检索纹理并使用这个2D上下文来绘制。
但是现在如果我要将ID2D1RenderTarget打印到打印机我必须如何进行? ("我的意思是纸张" -
在谷歌看到如何打印用于指定屏幕的奇怪之处:S )
欢迎使用桌面(WIN32)和UWP解决方案......我在两侧开发我的引擎。
// **** ************************************************** *********************
//输出:ID3D11Texture2D1 *
//类名:CRXMaterial
//函数名称: CreateEmptyTexture
//描述:创建一个空纹理
// ******************************* ********************************************
ID2D1RenderTarget * CRXMaterial :: GetTextureContext()
{
IDXGISurface2 * pDxgiSurface = NULL;
ID3D11Texture2D1 *纹理;
m_pTextureView-> GetResource((ID3D11Resource **)& Texture);
Texture-> QueryInterface(& pDxgiSurface);
D2D1_RENDER_TARGET_PROPERTIES props = D2D1 :: RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT,D2D1 :: PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,D2D1_ALPHA_MODE_PREMULTIPLIED),0,0);
ID2D1RenderTarget * Context = NULL;
m_pDirect3D-> GetD2DFactory() - > CreateDxgiSurfaceRenderTarget(pDxgiSurface,& props,& Context);
Texture-> Release();
pDxgiSurface-> Release();
返回上下文;
谢谢......
您好,
感谢您在此发布。
>>但是现在如果我将ID2D1RenderTarget打印到打印机我必须如何进行? ("我的意思是纸张" -
在谷歌上看到的打印用于指定屏幕的方式很奇怪:S )
对于这种情况,我建议你尝试使用
CreateBitmapFromDxgiSurface 方法,用于从DXGI曲面创建位图,可以将其设置为目标曲面或指定其他颜色上下文信息。然后使用打印机API打印出位图。
对于UWP解决方案,请在下面的论坛发帖。
https://social.msdn.microsoft.com/forums/windowsapps/en-us/home?forum=wpdevelop
希望这可以帮助你。
最好的问候,
Baron Bi
Hello,
I've create a 3D Engine and I can extract an ID2D1RenderTarget from an ID3D11ShaderResourceView1. Basically, I can retrieve texture from 3D Object and use this 2D Context to draw on.
But now if I will print ID2D1RenderTarget to printer how I must proceed? ("I mean Paper" -
its weird to see on google how print used to designated screen :S)
Desktop (WIN32) and UWP solution, was welcome... I develop my engine on both side.
//*************************************************************************** // Output : ID3D11Texture2D1* // Class name : CRXMaterial // Function name : CreateEmptyTexture // Description : Create a empty texture //*************************************************************************** ID2D1RenderTarget* CRXMaterial::GetTextureContext() { IDXGISurface2 *pDxgiSurface = NULL; ID3D11Texture2D1* Texture; m_pTextureView->GetResource((ID3D11Resource**)&Texture); Texture->QueryInterface(&pDxgiSurface); D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED), 0, 0); ID2D1RenderTarget* Context = NULL; m_pDirect3D->GetD2DFactory()->CreateDxgiSurfaceRenderTarget(pDxgiSurface, &props, &Context); Texture->Release(); pDxgiSurface->Release(); return Context;
Thanks...
Hi,
thanks for posting here.
>>But now if I will print ID2D1RenderTarget to printer how I must proceed? ("I mean Paper" - its weird to see on google how print used to designated screen :S)
For this case, I suggest you try to use CreateBitmapFromDxgiSurface method to create a bitmap from a DXGI surface that can be set as a target surface or have additional color context information specified. Then use printer API to print out the bitmap.
For UWP solution, please post on this forum below.
https://social.msdn.microsoft.com/forums/windowsapps/en-us/home?forum=wpdevelop
Hope this could be help of you.
Best Regards,
Baron Bi
这篇关于DirectX Surface到打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!