예제 #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);
        }
예제 #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;
        }
예제 #3
0
파일: Gdi32.cs 프로젝트: Longkong/Pojjaman
 public static extern IntPtr CreateBrushIndirect(ref LOGBRUSH brush);