ImageSize.cs 958 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Drawing;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace bbiwarg.Utility
  8. {
  9. public class ImageSize
  10. {
  11. public int Width {get; private set;}
  12. public int Height {get; private set;}
  13. public Vector2D MaxPixel {get; private set;}
  14. public float DiagonalLength { get { return MaxPixel.Length; } }
  15. public int NumPixels { get { return Width * Height; } }
  16. public ImageSize(int width, int height) {
  17. Width = width;
  18. Height = height;
  19. MaxPixel = new Vector2D(width - 1, height - 1);
  20. }
  21. public Vector2D getAbsolutePoint(Vector2D relativePoint) {
  22. return relativePoint.scale(MaxPixel);
  23. }
  24. public Vector2D getRelativePoint(Vector2D absolutePoint) {
  25. return new Vector2D(absolutePoint.X / Width, absolutePoint.Y / Height);
  26. }
  27. }
  28. }