OutputImage.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Drawing;
  7. using Emgu.CV;
  8. using Emgu.CV.Structure;
  9. namespace bbiwarg.Graphics
  10. {
  11. class OutputImage
  12. {
  13. public Image<Rgb, byte> Image { get; private set; }
  14. public OutputImage(int width, int height)
  15. {
  16. Image = new Image<Rgb, byte>(width, height);
  17. }
  18. public void drawLineSegment(bbiwarg.Utility.LineSegment2D lineSegment, byte r, byte g, byte b, int thickness = 1)
  19. {
  20. Image.Draw(new LineSegment2D(lineSegment.P1, lineSegment.P2), new Rgb(r, g, b), thickness);
  21. }
  22. public void drawContour(Contour<Point> contour, byte r, byte g, byte b, int thickness = 1)
  23. {
  24. Image.Draw(contour, new Rgb(r, g, b), thickness);
  25. }
  26. public void drawPoints(Seq<Point> points, byte r, byte g, byte b, int thickness = 1)
  27. {
  28. Image.Draw(points, new Rgb(r, g, b), thickness);
  29. }
  30. public void drawPixel(int x, int y, byte r, byte g, byte b)
  31. {
  32. Image.Data[y, x, 0] = r;
  33. Image.Data[y, x, 1] = g;
  34. Image.Data[y, x, 2] = b;
  35. }
  36. public void fillCircle(int x, int y, float radius, byte r, byte g, byte b)
  37. {
  38. Image.Draw(new CircleF(new PointF(x, y), radius), new Rgb(r, g, b), 0);
  39. }
  40. }
  41. }