예제 #1
0
        /*
         * Create code image, that carries provided value. Unit size is
         * radius of code finder pattern - resulting image size is unit*2 x unit*12.
         */
        public static Bitmap BuildCode(uint value, int unitSize)
        {
            Bitmap res = new Bitmap(unitSize * 12, unitSize * 2, PixelFormat.Format32bppArgb);

            Graphics g = Graphics.FromImage(res);

            g.DrawImageUnscaled(FinderCircleDrawer.GetFinderCircleImage(unitSize), new Point(0, 0));
            g.DrawImageUnscaled(DataMatrixDrawer.DataMatrix(DataMarshaller.MarshallInt(value), unitSize * 8, unitSize * 2), new Point(unitSize * 2, 0));
            g.DrawImageUnscaled(FinderCircleDrawer.GetFinderCircleImage(unitSize), new Point(unitSize * 10, 0));

            g.Dispose();

            return(res);
        }
예제 #2
0
        private static List <Point> CaclulateOffsetTable(int patternRadius, Func <int, int, bool> testPixel)
        {
            List <Point> pts    = new List <Point>();
            PointF       center = new PointF(0, 0);

            for (int cy = -patternRadius; cy <= patternRadius; cy++)
            {
                for (int cx = -patternRadius; cx <= patternRadius; cx++)
                {
                    PointF p     = new PointF(cx, cy);
                    float  r     = (float)PointOps.Distance(p, center) / patternRadius;
                    PointF prevP = new PointF(cx - 1, cy);
                    float  prevR = (float)PointOps.Distance(prevP, center) / patternRadius;
                    if (testPixel(FinderCircleDrawer.GetPixelAtRadius(prevR), FinderCircleDrawer.GetPixelAtRadius(r)))
                    {
                        pts.Add(new Point(cx, cy));
                    }
                }
            }
            return(pts);
        }