渐变填充位图和CreatePatternBrush只提供黑色填充而不是渐变

时间:2010-03-22 12:54:06

标签: c++ windows-mobile gdi

我正在尝试在Windows Mobile中创建一个Gradient Brush,如下所示:

HBITMAP hBitmap = CreateBitmap(16, 16, 1, 16, NULL);
HDC hDC = CreateCompatibleDC(NULL);
HBITMAP hPrevious = SelectObject(hDC, hBitmap);
TRIVERTEX vert[2];
GRADIENT_RECT gRect;
//... fill in vert and gRect
GradientFill(hDC, vert, 2, &gRect, 1, GRADIENT_FILL_RECT_V);
SelectObject(hDC, hPrevious);
Delete(hDC);

HBRUSH hPatternBrush = CreatePatternBrush(hBitmap);
HDC hDC = BeginPaint(hWnd, &ps);
SelectObject(hDC, hPatternBrush);
RoundRect(hDC, ...);
EndPaint(hWND, &ps);

绘制没有图案画笔的位图

  

HDC hdcSrc = CreateCompatibleDC(NULL);
  HGDIOBJ hbmOld = SelectObject(hdcSrc,hBitmap);
  BitBlt(hDC,...,hdcSrc,...,SRCCOPY);
  SelectObject(hdcSrc,hbmOld);
  DeleteDC(hdcSrc);

此代码创建一个黑色背景的圆形矩形,而不是图案画笔。我可以绘制用于创建画笔的hBitmap并绘制渐变。有人有解决方案吗?

0 个答案:

没有答案