zoukankan      html  css  js  c++  java
  • qrcodenet二维码图片下扩展区域添加号段的操作

    总监安排了个任务,一个号码导出一个二维码图, 我实现了最终还能批量生成,结果主管说要在图片下边添加一行,和图片是一起的

    最开始把控件的上的图给改了,结果保存起来没用,控件上的图跟要保存的不是一个事。

    最终找到在此方法中修改:

    程序是先绘制背景图。

    然后,把二维码的矩阵,小模块一个个打印出来。

    把y点的padding 数去掉,生成的图片就会升到背景图的顶部,觉得太靠顶了自己加个参数。

    Point modulePosition = new Point(preX * size.ModuleSize + padding + offset.X,
                                    y * size.ModuleSize + offset.Y);
    Point modulePosition = new Point(preX * size.ModuleSize + padding + offset.X,
                                y * size.ModuleSize  + offset.Y);
     
       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);
    
                if(QrMatrix == null || size.ModuleSize == 0)
                    return;
    
                int padding = (size.CodeWidth - (size.ModuleSize * width)) / 2;
    
                int preX = -1;
    
                for (int y = 0; y < width; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        if (QrMatrix[x, y])
                        {
                            //Set start point if preX == -1
                            if (preX == -1)
                                preX = x;
                            //If this is last module in that row. Draw rectangle
                            if (x == width - 1)
                            {
                                Point modulePosition = new Point(preX * size.ModuleSize + padding + offset.X,
                                    y * size.ModuleSize + offset.Y);
                                Size rectSize = new Size((x - preX + 1) * size.ModuleSize, size.ModuleSize);
                                graphics.FillRectangle(m_DarkBrush, modulePosition.X, modulePosition.Y, rectSize.Width, rectSize.Height);
                                preX = -1;
                            }
                        }
                        else if (!QrMatrix[x, y] && preX != -1)
                        {
                            //Here will be first light module after sequence of dark module.
                            //Draw previews sequence of dark Module
                            Point modulePosition = new Point(preX * size.ModuleSize + padding + offset.X,
                                y * size.ModuleSize  + offset.Y);
                            Size rectSize = new Size((x - preX) * size.ModuleSize, size.ModuleSize);
                            graphics.FillRectangle(m_DarkBrush, modulePosition.X, modulePosition.Y, rectSize.Width, rectSize.Height);
                            preX = -1;
                        }
                    }
                }
             
            }

     

  • 相关阅读:
    php模拟http请求的方法
    快递100接口开发
    live555从RTSP服务器读取数据到使用接收到的数据流程分析
    VLC源码分析知识总结
    VLC播放器架构剖析
    Android Audio System 之一:AudioTrack如何与AudioFlinger
    VLC各个Module模块之间共享变量的实现方法
    流媒体开发之--HLS--M3U8解析(2): HLS草案
    M3U8格式讲解及实际应用分析
    通用线程:POSIX 线程详解,第 3 部分 条件互斥量(pthread_cond_t)
  • 原文地址:https://www.cnblogs.com/zuochanzi/p/5980937.html
Copyright © 2011-2022 走看看