I am drawing lines by using win32 gdi native apis. Now, I want to draw the line as transparent. I have set the alpha channel property in the color. However, setting the alpha channel in color is not drawing the line as transparent. I read about Alpha Blend Api but could not figure out the solution.
var hdc = g.GdiDeviceContext;
var srcHdc = CreateCompatibleDC(hdc);
var clipRegion = CreateRectRgn(x, y, x + width, y + height);
SelectClipRgn(hdc, clipRegion);
var pen = CreatePen(PenStyle.Solid, LineWidth, (uint)ColorTranslator.ToWin32(colour));
if (pen != IntPtr.Zero)
{
var oldPen = SelectObject(hdc, pen);
Polyline(hdc, points, points.Length);
SelectObject(hdc, oldPen);
DeleteObject(pen);
}
SelectClipRgn(hdc, IntPtr.Zero);
AlphaBlend(hdc, x, y, width, height, srcHdc, x, y, width, height, new BlendFunction(0x00, 0, 0x7f, 0x00));
DeleteObject(clipRegion);
I am trying to draw the line as transparent.