Esempio n. 1
0
        public Bitmap DrawingBitmap()
        {
            DrawingModule();
            //  Graphics graphics = Graphics.FromImage(Bitmap);

            int R = ModuleSize / 4;

            for (int i = 0; i < ArrarContent.Count; i++)
            {
                // new Pen(Brushes.Red, 1)
                if (ArrarContent[i].BoolVar)
                {
                    Point point = new Point();
                    point.X = ArrarContent[i].Point.X * ModuleSize + R + QuietZoneModuleSize;
                    point.Y = ArrarContent[i].Point.Y * ModuleSize + R + QuietZoneModuleSize;

                    QrCodeGraphics.FillEllipse(Brushes.Black, new Rectangle(point.X, point.Y, ModuleSize / 2, ModuleSize / 2));

                    //QrCodeGraphics.FillRectangle(Brushes.Black, new Rectangle(point.X, point.Y, ModuleSize / 2, ModuleSize / 2));
                }
                else
                {
                    Point point = new Point()
                    {
                        X = ArrarContent[i].Point.X * ModuleSize + R + QuietZoneModuleSize,
                        Y = ArrarContent[i].Point.Y * ModuleSize + R + QuietZoneModuleSize
                    };
                    int b   = Bitmap.GetPixel(point.X, point.Y).B;
                    int g   = Bitmap.GetPixel(point.X, point.Y).G;
                    int r   = Bitmap.GetPixel(point.X, point.Y).R;
                    int rgb = (b + g + r) / 3;
                    if (rgb < 128)
                    {
                        QrCodeGraphics.FillEllipse(Brushes.White, new Rectangle(point.X, point.Y, ModuleSize / 2, ModuleSize / 2));

                        // QrCodeGraphics.FillRectangle(Brushes.White, new Rectangle(point.X, point.Y, ModuleSize / 2, ModuleSize / 2));
                    }
                }
            }
            QrCodeGraphics.Flush();
            QrCodeGraphics.Dispose();


            return(GetPixelWidth());
        }
Esempio n. 2
0
        private void DrawingModule()
        {
            for (int i = 0; i < Arraytagtopxend.Count; i++)
            {
                if (Arraytagtopxend[i].BoolVar)
                {
                    Point point = new Point()
                    {
                        X = Arraytagtopx[i].Point.X * ModuleSize + QuietZoneModuleSize,
                        Y = Arraytagtopx[i].Point.Y * ModuleSize + QuietZoneModuleSize
                    };
                    Point pointd = new Point()
                    {
                        X = Arraytagtopxend[i].Point.X * ModuleSize + QuietZoneModuleSize,
                        Y = Arraytagtopxend[i].Point.Y * ModuleSize + QuietZoneModuleSize
                    };
                    Point pointy = new Point()
                    {
                        X = Arraytagtopy[i].Point.X * ModuleSize + QuietZoneModuleSize,
                        Y = Arraytagtopy[i].Point.Y * ModuleSize + QuietZoneModuleSize
                    };

                    QrCodeGraphics.FillRectangle(Brushes.Black, new Rectangle(point.X, point.Y, ModuleSize, ModuleSize));

                    QrCodeGraphics.FillRectangle(Brushes.Black, new Rectangle(pointd.X, pointd.Y, ModuleSize, ModuleSize));

                    QrCodeGraphics.FillRectangle(Brushes.Black, new Rectangle(pointy.X, pointy.Y, ModuleSize, ModuleSize));
                }
            }
            QrCodeGraphics.Flush();


            //   Bitmap.Save(@"D:\Program Files\桌面\12112\DrawingModule.jpg");
            // Bitmap.Save(@"C:\Users\q4528\Desktop\1111111\DrawingModule.jpg");
            // QrCodeGraphics.Dispose();
        }