开发者

Gradient fill bitmap and CreatePatternBrush just gives black fill instead of gradient

I'm trying to create a Gradient Brush in windows mobile as follows:

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 = CreatePatternB开发者_如何学Gorush(hBitmap);
HDC hDC = BeginPaint(hWnd, &ps);
SelectObject(hDC, hPatternBrush);
RoundRect(hDC, ...);
EndPaint(hWND, &ps);

Draw the bitmap without pattern brush

HDC hdcSrc = CreateCompatibleDC(NULL);

HGDIOBJ hbmOld = SelectObject(hdcSrc, hBitmap);

BitBlt(hDC, ..., hdcSrc, ..., SRCCOPY);

SelectObject(hdcSrc, hbmOld);

DeleteDC(hdcSrc);

This code create a round rect with a black background, not the pattern brush. I can draw the hBitmap which is used to create the brush and it draws the gradient. Anyone got a solution?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜