How to draw a picture in the form of Nine Palace Grid with C#
This article mainly introduces how to use C#to draw pictures in the form of Jiugong grid, which has certain reference value. Interested friends can refer to it. I hope you will have a lot of gains after reading this article. Let Xiaobian take you to understand it together.
Method 1: Draw a straight line on the picture
The simplest and crudest way to think of is to draw the nine-square grid line directly on the picture. It looks like it has been cut into nine pieces. In fact, it is still a complete picture. The main code and effect are as follows:
m_startX = pnlCanvas.Width / 6; m_startY = pnlCanvas.Height / 6; m_imageWidth = pnlCanvas.Width - m_startX * 2; m_imageHeight = pnlCanvas.Height - m_startY * 2; e.Graphics.DrawImage(m_image, m_startX, m_startY, m_imageWidth, m_imageHeight); using (Pen p = new Pen(Brushes.White,m_lineWidth)) { int stepX = m_imageWidth / 3; int stepY = m_imageHeight / 3; for(int i=1;i