Fix LGS swapped resolution

LGS: Some plugins and slicers use XY resolution information, while others are swapped, a auto swap will be performed when required (#59)
This commit is contained in:
Tiago Conceição
2020-09-18 14:27:53 +01:00
parent c6eb192903
commit 44c9a2bcf1
3 changed files with 18 additions and 2 deletions
+1
View File
@@ -2,6 +2,7 @@
## /09/2020 - v0.8.2.3
* (Fix) LGS: Some plugins and slicers use XY resolution information, while others are swapped, a auto swap will be performed when required (#59)
## 16/09/2020 - v0.8.2.2
+10 -2
View File
@@ -44,8 +44,8 @@ namespace UVtools.Core.FileFormats
[FieldOrder(5)] public uint Uint_18 { get; set; } = 34; // 0x18: 34 ?
[FieldOrder(6)] public float PixelPerMmY { get; set; }
[FieldOrder(7)] public float PixelPerMmX { get; set; }
[FieldOrder(8)] public float ResolutionY { get; set; }
[FieldOrder(9)] public float ResolutionX { get; set; }
[FieldOrder(8)] public float ResolutionX { get; set; }
[FieldOrder(9)] public float ResolutionY { get; set; }
[FieldOrder(10)] public float LayerHeight { get; set; }
[FieldOrder(11)] public float ExposureTimeMs { get; set; }
[FieldOrder(12)] public float BottomExposureTimeMs { get; set; }
@@ -439,6 +439,14 @@ namespace UVtools.Core.FileFormats
throw new FileLoadException("Not a valid LGS file!", fileFullPath);
}
// Fix inconsistencies found of different version of plugin and slicers
if (ResolutionX > ResolutionY)
{
var oldX = ResolutionX;
ResolutionX = ResolutionY;
ResolutionY = oldX;
}
int previewSize = (int) (HeaderSettings.PreviewSizeX * HeaderSettings.PreviewSizeY * 2);
byte[] previewData = new byte[previewSize];
+7
View File
@@ -102,5 +102,12 @@ namespace UVtools.Core
{
return width * y + x;
}
public static void SwapVariables<T>(ref T var1, ref T var2)
{
var backup = var1;
var1 = var2;
var2 = backup;
}
}
}