ID2D1HwndRenderTarget always having black background instead of transparent(ID2D1HwndRenderTarget 总是有黑色背景而不是透明)
问题描述
我正在尝试创建一个简单的透明窗口,我可以在其中使用 Direct2D 进行绘图.
I am trying to create a simple transparent window where I can draw with Direct2D.
到目前为止我做了什么:
So far what I have done:
- 创建的窗口
- 将样式设置为 WS_EX_LAYERED
- 将 alpha 颜色键设置为 #FFF
- 使用 Windows 图形绘制一个白色矩形
- 现在窗口是透明的,具有每个像素的 Alpha 值
- 然后在窗口外制作一个目标并使用 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 总是有黑色背景而不是透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ID2D1HwndRenderTarget 总是有黑色背景而不是透明


基础教程推荐
- Windows Media Foundation 录制音频 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01