Live Chat Icon For mobile
Live Chat Icon

How to set the rendering origin for hatch brushes

Platform: WinForms| Category: Brushes

The Graphics.RenderingOrigin property lets you specify a Point structure that represents the dither origin for 8-bits-per-pixel and 16-bits-per-pixel dithering and is also used to set the origin for hatch brushes.

The following example shows how to use RenderingOrigin:


namespace Scrollable1
{
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Windows.Forms;

    /// 
    ///    Summary description for ScrollableControl1.
    /// 
    public class ScrollableControl1 : System.Windows.Forms.ScrollableControl
    {
        private void InitializeComponent ()
        {
        }
    
        public ScrollableControl1()
        {
            InitializeComponent ();

            this.AutoScrollMinSize = new Size(500, 500);
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
	pe.Graphics.RenderingOrigin = AutoScrollPosition;
            HatchBrush br = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Blue, Color.White);
            pe.Graphics.FillRectangle(br, ClientRectangle /*or pe.ClipRectangle*/);
            br.Dispose();
        }
    }
}

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.