namespace VisionCommon { public class TransformScaleTranslation { public double ScaleX { get; set; } = 1; public double ScaleY { get; set; } = 1; public double TranslationX { get; set; } = 0; public double TranslationY { get; set; } = 0; public TransformScaleTranslation() { } public TransformScaleTranslation( double sourceWidth, double sourceHeight, double targetWidth, double targetHeight) { this.ScaleX = targetWidth / sourceWidth; this.ScaleY = targetHeight / sourceHeight; if (ScaleX < ScaleY) { ScaleY = ScaleX; TranslationX = 0; TranslationY = (targetHeight - (sourceHeight * ScaleX)) * 0.5; } else { ScaleX = ScaleY; TranslationX = (targetWidth - (sourceWidth * ScaleY)) * 0.5; TranslationY = 0; } } } }