public Pen(Color color, int width, PenEndCapStyle capStyle = PenEndCapStyle.Round, PenJoinCapStyle joinStyle = PenJoinCapStyle.Round) { int styleValue = 0; switch (capStyle) { case PenEndCapStyle.Round: styleValue |= GDIConstants.PS_ENDCAP_ROUND; break; case PenEndCapStyle.Flat: styleValue |= GDIConstants.PS_ENDCAP_FLAT; break; case PenEndCapStyle.Square: styleValue |= GDIConstants.PS_ENDCAP_SQUARE; break; } switch (joinStyle) { case PenJoinCapStyle.Round: styleValue |= GDIConstants.PS_JOIN_ROUND; break; case PenJoinCapStyle.Bevel: styleValue |= GDIConstants.PS_JOIN_BEVEL; break; case PenJoinCapStyle.Miter: styleValue |= GDIConstants.PS_JOIN_MITER; break; } LOGBRUSH brush = new LOGBRUSH(); brush.lbColor = Color.ToWin32Color(color); Handle = NativeMethods.ExtCreatePen(styleValue, width, ref brush, 0, Array.Empty <int>()); }
private static IntPtr GetHalfToneBrush() { if (m_halfToneBrush == IntPtr.Zero) { Bitmap bitmap = new Bitmap(8, 8, PixelFormat.Format32bppArgb); Color white = Color.FromArgb(255, 255, 255, 255); Color black = Color.FromArgb(255, 0, 0, 0); bool flag = true; // Alternate black and white pixels across all lines for (int x = 0; x < 8; x++, flag = !flag) { for (int y = 0; y < 8; y++, flag = !flag) { bitmap.SetPixel(x, y, (flag ? white : black)); } } IntPtr hBitmap = bitmap.GetHbitmap(); LOGBRUSH brush = new LOGBRUSH(); brush.lbStyle = (uint)Win32.BrushStyles.BS_PATTERN; brush.lbHatch = (uint)hBitmap; m_halfToneBrush = Gdi32.CreateBrushIndirect(ref brush); Gdi32.DeleteObject(hBitmap); } return(m_halfToneBrush); }
public static extern int ExtCreatePen( int dwPenStyle, int dwWidth, ref LOGBRUSH lplb, int dwStyleCount, ref int lpStyle );
IntPtr CreateLineBrush() { short[] grayPattern = new short[8]; for (int i = 0; i < 2; i++) { grayPattern[i] = 0xff; } IntPtr hBitmap = CreateBitmap(2, 2, 1, 1, grayPattern); LOGBRUSH lb = new LOGBRUSH(BS_PATTERN, 0, hBitmap); IntPtr brush = CreateBrushIndirect(lb); DeleteObject(hBitmap); return(brush); }
IntPtr CreateSplitBrush() { short[] grayPattern = new short[8]; for (int i = 0; i < 8; i++) { grayPattern[i] = (short)(0x5555 << (i & 1)); } IntPtr hBitmap = CreateBitmap(8, 8, 1, 1, grayPattern); LOGBRUSH lb = new LOGBRUSH(BS_PATTERN, 0, hBitmap); IntPtr brush = CreateBrushIndirect(lb); DeleteObject(hBitmap); return(brush); }
public static PenHandle CreatePen(PenStyleExtended style, uint width, COLORREF color, PenEndCap endCap = PenEndCap.Round, PenJoin join = PenJoin.Round) { LOGBRUSH brush = new LOGBRUSH { lbColor = color, lpStyle = BrushStyle.Solid }; return(Imports.ExtCreatePen( (uint)style | (uint)PenType.Geometric | (uint)endCap | (uint)join, width, ref brush, 0, null)); }
public static IntPtr CreateExtPen(HCPen aPen) { LOGBRUSH vPenParams = new LOGBRUSH(); switch (aPen.Style) { case HCPenStyle.psSolid: case HCPenStyle.psInsideFrame: vPenParams.lbStyle = GDI.PS_SOLID; break; case HCPenStyle.psDash: vPenParams.lbStyle = GDI.PS_DASH; break; case HCPenStyle.psDot: vPenParams.lbStyle = GDI.PS_DOT; break; case HCPenStyle.psDashDot: vPenParams.lbStyle = GDI.PS_DASHDOT; break; case HCPenStyle.psDashDotDot: vPenParams.lbStyle = GDI.PS_DASHDOTDOT; break; case HCPenStyle.psClear: vPenParams.lbStyle = GDI.PS_NULL; break; default: vPenParams.lbStyle = GDI.PS_SOLID; break; } vPenParams.lbColor = aPen.Color.ToRGB_UInt(); vPenParams.lbHatch = 0; if (aPen.Width != 1) { return((IntPtr)(GDI.ExtCreatePen(GDI.PS_GEOMETRIC | GDI.PS_ENDCAP_SQUARE, aPen.Width, ref vPenParams, 0, IntPtr.Zero))); } else { return((IntPtr)(GDI.ExtCreatePen(GDI.PS_COSMETIC | GDI.PS_ENDCAP_SQUARE, aPen.Width, ref vPenParams, 0, IntPtr.Zero))); } }
public static extern IntPtr CreateBrushIndirect([In] ref LOGBRUSH lplb);
public static extern IntPtr CreateBrushIndirect(ref LOGBRUSH brush);
public static extern IntPtr ExtCreatePen(uint iPenStyle, uint cWidth, [In] ref LOGBRUSH plbrush, uint cStyle, [In] IntPtr pstyle);
public static extern IntPtr CreateBrushIndirect(ref LOGBRUSH brush);
public static extern IntPtr ExtCreatePen(int style, int nWidth, LOGBRUSH logbrush, int styleArrayLength, int[] styleArray);
public HCBrush() { FLogBrush = new LOGBRUSH(); ReCreateHandle(); }
static extern IntPtr CreateBrushIndirect(LOGBRUSH lb);
public static extern Win32ObjectSafeHandle ExtCreatePen(uint dwPenStyle, uint dwWidth, ref LOGBRUSH lplb, uint dwStyleCount, [In][Out] uint[] lpStyle);
static extern IntPtr ExtCreatePen(UInt32 dwPenStyle, UInt32 dwWidth, ref LOGBRUSH lplb, UInt32 dwStyleCount, UInt32[] lpStyle);
static extern IntPtr ExtCreatePen(UInt32 dwPenStyle, UInt32 dwWidth, ref LOGBRUSH lplb, UInt32 dwStyleCount, UInt32[] lpStyle);
internal static extern IntPtr ExtCreatePen(PenStyle dwPenStyle, uint dwWidth, [In] ref LOGBRUSH lplb, uint dwStyleCount, uint[] lpStyle);
public static extern PenHandle ExtCreatePen( uint dwPenStyle, uint dwWidth, [In] ref LOGBRUSH lplb, uint dwStyleCount, uint[] lpStyle);
public static extern IntPtr ExtCreatePen(int style, int nWidth, LOGBRUSH logbrush, int styleArrayLength, int[] styleArray);
public static IntPtr CreateBrushIndirect(LOGBRUSH lpLogBrush) { NotImplemented(MethodBase.GetCurrentMethod()); return(IntPtr.Zero); }
public unsafe static extern HPEN ExtCreatePen(PS fnStyle, int dwWidth, ref LOGBRUSH lplb, uint dwStyleCount, uint *lpStyle);
public static extern HBRUSH CreateBrushIndirect(ref LOGBRUSH lb);