using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
namespace bbiwarg.Utility
{
///
/// Manages the size of a image.
///
public class ImageSize
{
///
/// image width
///
public int Width {get; private set;}
///
/// image height
///
public int Height {get; private set;}
///
/// position in the image with maximum x and y values
///
public Vector2D MaxPixel {get; private set;}
///
/// the length of the longer image diagonal
///
public float DiagonalLength { get { return MaxPixel.Length; } }
///
/// number of pixels in the image
///
public int NumPixels { get { return Width * Height; } }
///
/// 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.
///
/// realtive 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
/// realtive point (x and y in [0,1])
public Vector2D getRelativePoint(Vector2D absolutePoint) {
return new Vector2D(absolutePoint.X / Width, absolutePoint.Y / Height);
}
}
}