如何创建共享位图(想要与WIC共享使用Direct2D创建的位图) [英] How to create a shared bitmap (would like to share a bitmap created with Direct2D with WIC)

查看:360
本文介绍了如何创建共享位图(想要与WIC共享使用Direct2D创建的位图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的WIC代码中使用使用Direct2D上下文创建的'ID2D1Bitmap1'对象。这是示例代码。

I would like to use 'ID2D1Bitmap1' object created using Direct2D context in my WIC code. Here is example code.

我尝试执行以下操作但是我收到错误并且还尝试创建sharedBitmap(不确定如何正确创建它,您能指出我的任何示例吗? )这对我也不起作用。

I tried to do the following but I am getting errors and also tried to create sharedBitmap (not sure how to create it properly, can you point me to any examples?) and that too does not work for me.

谢谢

PB

// D2D Bitmap

ComPtr<ID2DBitmap1> d2dBitMap;
m_d2dContext->CreateBitmap(..., &d2dBitMap);

...........

// My WIC code

ID2D1RenderTarget imgRenderTarget;
m_d2dFactory->CreateWicBitmapRenderTarget(imgWicBitMap.Get(), ..., &imgRenderTarget);

// I am getting error here

imgRenderTarget->BeginDraw();
imgRenderTarget->DrawBitmap(d2dBitMap.Get(), resultImagePos, 1.0F, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
hr = imgRenderTarget->EndDraw();







推荐答案

CreateWicBitmapRenderTarget需要IWICBitmap作为第一个参数。

在您的代码中传递ID2DBitmap1

CreateWicBitmapRenderTarget needs IWICBitmap as the first parameters.
In your codes you pass a ID2DBitmap1

您可以按照这些代码

		ComPtr<IWICBitmap> bitmap = NULL; 
	
		DX::ThrowIfFailed(
		m_wicFactory->CreateBitmap(600,800, GUID_WICPixelFormat32bppPBGRA,WICBitmapCacheOnLoad,&bitmap)
		); 
		ComPtr<ID2D1RenderTarget> imgRenderTarget;
		D2D1_RENDER_TARGET_PROPERTIES rtProps = D2D1::RenderTargetProperties();
		rtProps.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED);
		rtProps.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
		rtProps.usage = D2D1_RENDER_TARGET_USAGE_NONE;

		DX::ThrowIfFailed(
			m_d2dFactory->CreateWicBitmapRenderTarget(bitmap.Get(),rtProps,&imgRenderTarget)
		);



最好的问候,

Jesse


Best regards,
Jesse


这篇关于如何创建共享位图(想要与WIC共享使用Direct2D创建的位图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆