namespace BBIWARG.Utility { /// /// Manages the size of a image. /// public class ImageSize { /// /// the length of the longer image diagonal /// public float DiagonalLength { get { return MaxPixel.Length; } } /// /// image height /// public int Height { get; private set; } /// /// position in the image with maximum x and y values /// public Vector2D MaxPixel { get; private set; } /// /// number of pixels in the image /// public int NumPixels { get { return Width * Height; } } /// /// image width /// public int Width { get; private set; } /// /// Constructs a ImageSize. /// /// image width /// image height public ImageSize(int width, int height) { Width = width; Height = height; MaxPixel = new Vector2D(width - 1, height - 1); } /// /// Computes an absolute point in the image. /// /// relative point (x and y in [0,1]) /// absolute point public Vector2D getAbsolutePoint(Vector2D relativePoint) { return relativePoint.scale(MaxPixel); } /// /// Computes a relative point in the image. /// /// absolute point in the image /// relative point (x and y in [0,1]) public Vector2D getRelativePoint(Vector2D absolutePoint) { return new Vector2D(absolutePoint.X / Width, absolutePoint.Y / Height); } } }