34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|