ClassLibraryWeiBao/QR二维码/Windows/Render/GraphicsRenderer.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using System;

namespace Gma.QrCodeNet.Encoding.Windows.Render
{
    public class GraphicsRenderer
    {
        private Brush m_DarkBrush;
        private Brush m_LightBrush;

        private ISizeCalculation m_iSize;

        /// <summary>
        /// Initialize Renderer. Default brushes will be black and white.
        /// </summary>
        /// <param name="iSize">The way of calculate Size</param>
        public GraphicsRenderer(ISizeCalculation iSize)
            : this(iSize, Brushes.Black, Brushes.White)
        {
        }

        /// <summary>
        /// Initialize Renderer
        /// </summary>
        /// <param name="iSize">The way of calculate Size</param>
        public GraphicsRenderer(ISizeCalculation iSize, Brush darkBrush, Brush lightBrush)
        {
            m_iSize = iSize;

            m_DarkBrush = darkBrush;
            m_LightBrush = lightBrush;
        }

        /// <summary>
        /// Drawing Bitmatrix to winform graphics.
        /// Default position will be 0, 0
        /// </summary>
        /// <param name="matrix">Draw background only for null matrix</param>
        /// <exception cref="ArgumentNullException">DarkBrush or LightBrush is null</exception>
        public void Draw(Graphics graphics, BitMatrix QrMatrix)
        {
            this.Draw(graphics, QrMatrix, new Point(0, 0));
        }

        /// <summary>
        /// Drawing Bitmatrix to winform graphics.
        /// </summary>
        /// <param name="QrMatrix">Draw background only for null matrix</param>
        /// <exception cref="ArgumentNullException">DarkBrush or LightBrush is null</exception>
        public void Draw(Graphics graphics, BitMatrix QrMatrix, Point offset)
        {
            int width = QrMatrix == null ? 21 : QrMatrix.Width;

            DrawingSize size = m_iSize.GetSize(width);

            graphics.FillRectangle(m_LightBrush, offset.X, offset.Y, size.CodeWidth, size.CodeWidth);

后面还有 147 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。