ID2D1HwndRenderTarget 总是有黑色背景而不是透明 [英] ID2D1HwndRenderTarget always having black background instead of transparent

查看:12
本文介绍了ID2D1HwndRenderTarget 总是有黑色背景而不是透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个简单的透明窗口,我可以在其中使用 Direct2D 进行绘图.

I am trying to create a simple transparent window where I can draw with Direct2D.

到目前为止我做了什么:

So far what I have done:

  1. 创建的窗口
  2. 将样式设置为 WS_EX_LAYERED
  3. 将 alpha 颜色键设置为 #FFF
  4. 使用 Windows 图形绘制一个白色矩形
  5. 现在窗口是透明的,具有每个像素的 Alpha 值
  6. 然后在窗口外制作一个目标并使用 Direct2D 进行绘制
    • 制作 ALPHA _PREMULIPLIED 目标
    • 使用 0.0f alpha 的 #FFF 清除

我只是不知道如何使窗口透明.如果您能指出我的错误,我将不胜感激

I just don't know how to make window to transparent. If you can point out my mistake, I would be obliged

推荐答案

我认为使用 directX 是不可能的.不过 GDI 确实有效.

I don't think it's possible with directX. However GDI does work.

在此处查看源代码以了解它是如何完成的:http://pastebin.com/NJf8wi2V

Take a look at the source here to see how it's done: http://pastebin.com/NJf8wi2V

在源代码中,您可以看到有一个尝试使用 directx/opengl 的选项.但是,正如您从运行中看到的那样,它们不起作用.

In the source you can see that there is an option to attempt to use directx/opengl. However as you can see from running they do not work.

这篇关于ID2D1HwndRenderTarget 总是有黑色背景而不是透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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