层窗口(WS_EX_LAYERED),先用DrawImage画了一张PNG图片上去当背景
然后用DrawString在上面写字
Font font(L"宋体",12,FontStyleRegular,UnitPixel);
StringFormat strFormat;
SolidBrush brush(Color(0xff,0,0,0));
graphics.DrawString(L"test string",-1,&font,PointF(0,0),&strFormat,&brush);
发现写出来的字把图片给透明了,相当于在图片上挖了个洞 BLENDFUNCTION blend;
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.AlphaFormat = AC_SRC_ALPHA;
blend.SourceConstantAlpha = 255; ::UpdateLayeredWindow(m_hWnd,...,RGB(0,0,0),&blend,ULW_ALPHA);
然后用DrawString在上面写字
Font font(L"宋体",12,FontStyleRegular,UnitPixel);
StringFormat strFormat;
SolidBrush brush(Color(0xff,0,0,0));
graphics.DrawString(L"test string",-1,&font,PointF(0,0),&strFormat,&brush);
发现写出来的字把图片给透明了,相当于在图片上挖了个洞 BLENDFUNCTION blend;
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.AlphaFormat = AC_SRC_ALPHA;
blend.SourceConstantAlpha = 255; ::UpdateLayeredWindow(m_hWnd,...,RGB(0,0,0),&blend,ULW_ALPHA);
解决方案 »
- C++ 如何判断系统是否做过S3,S4,RESTART
- WDK6开发环境设置问题,添加新的头文件会报找不到
- 如何从一个二维数组中挑选重复数字,然后输出到文件中
- 关于using 关键字的使用
- vc.net 菜鸟问题,在线等
- 我的toolbar有一个BMP图像,背景色是白色的,我想要做成透明,掩码怎么设呢???是不是RGB(255,255,255)???
- 各位看一下这个想法好不好实现?
- vc6.0打开Ecxel2000怎样写代码?
- easy 问题---如何获得系统的语言类型?是中文版还是英文版?
- 一个关于高级程序员的问题,感兴趣的请进
- 有没有什么方法通过程序直接设定修改默认打印机的设置?
- 外包--msn yahoo通发信息
Color::Transparent,不行
Can I cancel this???
层窗口(WS_EX_LAYERED),用UpdateLayeredWindow输出的文字(用常规方法输出的:TextOut、DrawText、DrawString...),并且设置了AC_SRC_ALPHA和ULW_ALPHA,就会存在这种错误解决方案就是:
用GraphicsPath来代替文字输出
path.AddString(...);
pGraph->FillPath(&brush,&path);这样,默认的输出的文字质量很差,可以设置Graphics的SmoothingMode为SmoothingModeHighQuality