示例#1
0
 public void CreateGreyscale()
 {
     using (Bitmap b = new Bitmap(100, 100))
     {
         using (Graphics g = b.GetGraphics())
         {
             using (LinearGradientBrush brush = new LinearGradientBrush(
               new Rectangle(0, 0, 100, 100),
               Color.Blue,
               Color.Red,
               LinearGradientMode.Vertical))
             {
                 brush.SetSigmaBellShape(0.5f);
                 g.FillRectangle(brush, new Rectangle(0, 0, 100, 100));
                 using (Bitmap b2 = (Bitmap)b.CreateGreyscale())
                 {
                     if (ShowTestForm(b2) != DialogResult.OK)
                     {
                         Assert.Fail();
                     }
                 }
             }
         }
     }
 }
示例#2
0
 public void GetGraphics()
 {
     using (Bitmap b = new Bitmap(100, 100))
     {
         using (Graphics g = b.GetGraphics())
         {
             g.DrawString("Hello World", new Font("Arial", 10), Brushes.Red, new PointF(0, 0));
         }
         if (ShowTestForm(b) != DialogResult.OK)
         {
             Assert.Fail();
         }
     }
 }
示例#3
0
文件: Report.cs 项目: hcesar/Chess
        public void GenerateFixationMap(string subject)
        {
            var path = "maps\\" + subject.Replace(".volke", "");
            if (!Directory.Exists("maps")) Directory.CreateDirectory("maps");
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);

            int idx = 0;
            foreach (var fixation in this.GetFixations())
            {
                var x = (float)fixation.Average(i => i.LeftEye.X);
                var y = (float)fixation.Average(i => i.LeftEye.Y);
                using (var g = this.BoardImage.GetGraphics())
                {
                    g.Graphics.DrawEllipse(Pens.Red, x, y, 100f, 100f);
                    g.Graphics.DrawString((++idx).ToString(), new Font("Arial", 12), Brushes.Red, x, y);
                }
            }

            var bmp = new Bitmap(850, 900);

            using (var g = bmp.GetGraphics())
            {
                g.Graphics.DrawString(this.Test.Question, new Font("Calibri", 12), Brushes.Black, 5, 5);
                g.Graphics.DrawString(this.Test.IsCorrect ? "SIM" : "NÃO", new Font("Calibri", 12, FontStyle.Bold), Brushes.Black, 5, 22);
                g.Graphics.DrawImageUnscaled(this.BoardImage, 0, 80);
            }

            bmp.Save(path + "\\" + this.Test.Id + ".png");
        }
示例#4
0
文件: Report.cs 项目: hcesar/Chess
        public void GenerateHeatMap(string subject)
        {
            var path = "maps\\" + subject.Replace(".volke", "");
            if (!Directory.Exists("maps")) Directory.CreateDirectory("maps");
            if (!Directory.Exists(path)) Directory.CreateDirectory(path);

            int maskSize = 150;
            var mask = GetMask(maskSize);
            int[,] exposure = new int[850, 850];

            LookPoint.Filters.WeightOOTriangular filter = new LookPoint.Filters.WeightOOTriangular();
            int filterCount = 0;

            foreach (var eyeTracking in this.GetFixations().SelectMany(i => i))
            {
                var mx = (eyeTracking.LeftEye.X + eyeTracking.RightEye.X) / 2;
                var my = (eyeTracking.LeftEye.Y + eyeTracking.RightEye.Y) / 2;
                var fp = filter.feed(++filterCount * 20, new PointF((float)mx, (float)my));
                var point = new Point((int)fp.X, (int)fp.Y);

                if (point.X < 0 || point.Y < 0 || point.X >= 850 || point.Y >= 850)
                    continue;

                int exposureValue = 10;
                for (int x = 0; x < maskSize; x++)
                {
                    int targetX = point.X - (maskSize / 2) + x;
                    if (targetX < 0 || targetX >= 850) continue;

                    for (int y = 0; y < maskSize; y++)
                    {
                        int targetY = point.Y - (maskSize / 2) + y;
                        if (targetY < 0 || targetY >= 850 || mask[x, y] == 0) continue;

                        exposure[targetX, targetY] += exposureValue * mask[x, y];
                    }
                }
            }

            float max = exposure.Cast<int>().Max();

            for (int x = 0; x < 850; x++)
                for (int y = 0; y < 850; y++)
                    this.BoardImage.SetPixel(x, y, GetColor(this.BoardImage.GetPixel(x, y), exposure[x, y], max));

            var bmp = new Bitmap(850, 900);

            using (var g = bmp.GetGraphics())
            {
                g.Graphics.DrawString(this.Test.Question, new Font("Calibri", 12), Brushes.Black, 5, 5);
                g.Graphics.DrawString(this.Test.IsCorrect ? "SIM" : "NÃO", new Font("Calibri", 12, FontStyle.Bold), Brushes.Black, 5, 22);
                g.Graphics.DrawImageUnscaled(this.BoardImage, 0, 80);
            }

            bmp.Save(path + "\\" + this.Test.Id + ".png");
        }