Example #1
0
        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();

                Win32.LOGBRUSH brush = new Win32.LOGBRUSH();

                brush.lbStyle = (uint)Win32.BrushStyles.BS_PATTERN;
                brush.lbHatch = (uint)hBitmap;

                m_halfToneBrush = Gdi32.CreateBrushIndirect(ref brush);
                Gdi32.DeleteObject(hBitmap);
            }

            return(m_halfToneBrush);
        }
Example #2
0
        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();

                Win32.LOGBRUSH brush = new Win32.LOGBRUSH();

                brush.lbStyle = (uint)Win32.BrushStyles.BS_PATTERN;
                brush.lbHatch = (uint)hBitmap;

                m_halfToneBrush = Gdi32.CreateBrushIndirect(ref brush);
                Gdi32.DeleteObject(hBitmap);
            }

            return m_halfToneBrush;
        }
Example #3
0
 public static extern IntPtr CreateBrushIndirect(ref LOGBRUSH brush);