创建阴影线画刷
来源:互联网 发布:燕京啤酒 知乎 编辑:程序博客网 时间:2024/04/28 17:23
=============================================================
标题:创建阴影线画刷
摘要:
备注:Windows CE
日期:2010.5.1
姓名:朱铭雷
=============================================================
填充棒图,图表的时候,使用阴影线画刷能够使之更加醒目。其他版本的Windows系统可以通过CreateHatchBrush函数来创建,但Windows CE下不支持这个函数,只能通过其他方法来实现。
下面这个函数,摘自《Programming Windows Embedded CE 6.0 Developer Reference》,可以完成这个功能。
#define HS_HORIZONTAL 0 /* ----- */
#define HS_VERTICAL 1 /* ||||| */
#define HS_FDIAGONAL 2 /* ///// */
#define HS_BDIAGONAL 3 /* ///// */
#define HS_CROSS 4 /* +++++ */
#define HS_DIAGCROSS 5 /* xxxxx */
//----------------------------------------------------------------
// MyCreateHatchBrush - Creates hatched brushes
//
HBRUSH MyCreateHatchBrush (INT fnStyle, COLORREF clrref) {
BRUSHBMP brbmp;
BYTE *pBytes;
int i;
DWORD dwBits[6][2] = {
{0x000000ff,0x00000000}, {0x10101010,0x10101010},
{0x01020408,0x10204080}, {0x80402010,0x08040201},
{0x101010ff,0x10101010}, {0x81422418,0x18244281},
};
if ((fnStyle < 0) || (fnStyle > dim(dwBits)))
return 0;
memset (&brbmp, 0, sizeof (brbmp));
brbmp.bmi.biSize = sizeof (BITMAPINFOHEADER);
brbmp.bmi.biWidth = 8;
brbmp.bmi.biHeight = 8;
brbmp.bmi.biPlanes = 1;
brbmp.bmi.biBitCount = 1;
brbmp.bmi.biClrUsed = 2;
brbmp.bmi.biClrImportant = 2;
// Initialize the palette of the bitmap.
brbmp.dwPal[0] = PALETTERGB(0xff,0xff,0xff);
brbmp.dwPal[1] = PALETTERGB((BYTE)((clrref >> 16) & 0xff),
(BYTE)((clrref >> 8) & 0xff),
(BYTE)(clrref & 0xff));
// Write the hatch data to the bitmap.
pBytes = (BYTE *)&dwBits[fnStyle];
for (i = 0; i < 8; i++)
brbmp.bBits[i*4] = *pBytes++;
// Return the handle of the brush created.
return CreateDIBPatternBrushPt (&brbmp, DIB_RGB_COLORS);
}
使用的时候,直接调用这个函数来创建阴影线画刷就可以了。如下:
HBRUSH hBr, hOldBr;
hBr = (HBRUSH) MyCreateHatchBrush (HS_DIAGCROSS, RGB (0, 0, 0));
hOldBr = (HBRUSH) SelectObject (hdc, hBr);
Rectangle (hdc, 100, 100, 140, 200);
SelectObject (hdc, hOldBr);
DeleteObject (hBr);
效果如下:
- 创建阴影线画刷
- 创建阴影效果
- html5 canvas学习--创建阴影
- D3DXMatrixShadow创建一个平面的阴影矩阵
- WPF-创建具有阴影的文本
- D3DXMatrixShadow创建一个平面的阴影矩阵
- 创建没有黑色阴影的自定义dialog
- html5创建变换图形-阴影图形
- 利用layer-list创建阴影效果等
- 阴影线画刷样式
- 阴影
- 阴影
- 阴影
- 阴影
- 阴影
- 阴影
- 阴影
- 阴影
- 博客开张了
- 使用TAPI开发电话防火墙程序
- 清除句中回车的小工具
- apue.h头文件的配置
- 在ogre里面显示二维图片
- 创建阴影线画刷
- 关于windows mobile中Http 开发
- windows下的ReadFile与Linux下的pread
- 字符串回文
- 据说不伤眼睛的文字背景色
- Connect by实现树查询的妙用
- 关于手机短信(SMS)工作原理
- 为linux配置telnet服务
- 目标 2010.5.2