@@ -80,7 +80,7 @@ public enum PhotonRleFormat
8080 PWS ,
8181 PW0
8282 }
83-
83+
8484 public enum AnyCubicMachine : byte
8585 {
8686 PhotonS ,
@@ -152,7 +152,7 @@ public class FileMark
152152 /// <summary>
153153 /// Spotted on version 515 only
154154 /// </summary>
155- [ FieldOrder ( 6 ) ] public uint LayerImageColorTableAddress { get ; set ; }
155+ [ FieldOrder ( 6 ) ] public uint LayerImageColorTableAddress { get ; set ; }
156156
157157 /// <summary>
158158 /// Gets the layer definition start address
@@ -269,7 +269,7 @@ public override string ToString()
269269 /// <param name="lengthOffset">Offset to length</param>
270270 /// <exception cref="FileLoadException"></exception>
271271 public void Validate ( bool validateName , int lengthOffset = 0 ) => ValidateExpecting ( ( int ) GetFinalTableLength ( ) + lengthOffset , validateName ) ;
272-
272+
273273 public void Validate ( sbyte lengthOffset ) => Validate ( true , lengthOffset ) ;
274274 public void Validate ( byte lengthOffset ) => Validate ( true , lengthOffset ) ;
275275 public void Validate ( ushort lengthOffset ) => Validate ( true , lengthOffset ) ;
@@ -317,12 +317,12 @@ public sealed class Header : AnycubicNamedTable
317317
318318 [ FieldOrder ( 4 ) ] public float WaitTimeBeforeCure { get ; set ; } = 1 ;
319319
320- [ FieldOrder ( 5 ) ] public float BottomExposureTime { get ; set ; }
320+ [ FieldOrder ( 5 ) ] public float BottomExposureTime { get ; set ; }
321321
322322 [ FieldOrder ( 6 ) ] public float BottomLayersCount { get ; set ; }
323323
324324 [ FieldOrder ( 7 ) ] public float LiftHeight { get ; set ; } = DefaultLiftHeight ;
325-
325+
326326 /// <summary>
327327 /// Gets the lift speed in mm/s
328328 /// </summary>
@@ -784,7 +784,7 @@ private unsafe Mat DecodePWS(AnycubicFile slicerFile)
784784
785785 span [ i ] = ( byte ) newC ;
786786 }
787-
787+
788788 return image ;
789789 }
790790
@@ -1065,7 +1065,7 @@ public override string ToString()
10651065 new ( typeof ( AnycubicFile ) , "pwc" , "Anycubic Custom Machine (PWC)" ) ,
10661066 //new(typeof(PhotonWorkshopFile), "pwmb", "Photon M3 Plus (PWMB)"),
10671067 } ;
1068-
1068+
10691069 public override SpeedUnit FormatSpeedUnit => SpeedUnit . MillimetersPerSecond ;
10701070
10711071 public override PrintParameterModifier [ ] PrintParameterModifiers
@@ -1382,8 +1382,8 @@ public override float ExposureTime
13821382
13831383 public override float BottomLiftHeight
13841384 {
1385- get => FileMarkSettings . Version >= VERSION_516
1386- ? ExtraSettings . BottomLiftHeight1
1385+ get => FileMarkSettings . Version >= VERSION_516
1386+ ? ExtraSettings . BottomLiftHeight1
13871387 : base . BottomLiftHeight ;
13881388 set
13891389 {
@@ -1405,7 +1405,7 @@ public override float BottomLiftHeight
14051405 public override float BottomLiftSpeed
14061406 {
14071407 get => FileMarkSettings . Version >= VERSION_516
1408- ? SpeedConverter . Convert ( ExtraSettings . BottomLiftSpeed1 , FormatSpeedUnit , CoreSpeedUnit )
1408+ ? SpeedConverter . Convert ( ExtraSettings . BottomLiftSpeed1 , FormatSpeedUnit , CoreSpeedUnit )
14091409 : base . BottomLiftSpeed ;
14101410 set
14111411 {
@@ -1417,8 +1417,8 @@ public override float BottomLiftSpeed
14171417
14181418 public override float LiftHeight
14191419 {
1420- get => FileMarkSettings . Version >= VERSION_516
1421- ? ExtraSettings . LiftHeight1
1420+ get => FileMarkSettings . Version >= VERSION_516
1421+ ? ExtraSettings . LiftHeight1
14221422 : HeaderSettings . LiftHeight ;
14231423 set
14241424 {
@@ -1440,7 +1440,7 @@ public override float LiftHeight
14401440 public override float LiftSpeed
14411441 {
14421442 get => SpeedConverter . Convert ( FileMarkSettings . Version >= VERSION_516
1443- ? ExtraSettings . LiftSpeed1
1443+ ? ExtraSettings . LiftSpeed1
14441444 : HeaderSettings . LiftSpeed , FormatSpeedUnit , CoreSpeedUnit ) ;
14451445 set
14461446 {
@@ -1453,7 +1453,7 @@ public override float LiftSpeed
14531453 public override float BottomLiftHeight2
14541454 {
14551455 get => FileMarkSettings . Version >= VERSION_516
1456- ? ExtraSettings . BottomLiftHeight2
1456+ ? ExtraSettings . BottomLiftHeight2
14571457 : 0 ;
14581458 set
14591459 {
@@ -1470,7 +1470,7 @@ public override float BottomLiftHeight2
14701470 public override float BottomLiftSpeed2
14711471 {
14721472 get => FileMarkSettings . Version >= VERSION_516
1473- ? SpeedConverter . Convert ( ExtraSettings . BottomLiftSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1473+ ? SpeedConverter . Convert ( ExtraSettings . BottomLiftSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
14741474 : 0 ;
14751475 set
14761476 {
@@ -1484,7 +1484,7 @@ public override float BottomLiftSpeed2
14841484 public override float LiftHeight2
14851485 {
14861486 get => FileMarkSettings . Version >= VERSION_516
1487- ? ExtraSettings . LiftHeight2
1487+ ? ExtraSettings . LiftHeight2
14881488 : 0 ;
14891489 set
14901490 {
@@ -1500,8 +1500,8 @@ public override float LiftHeight2
15001500
15011501 public override float LiftSpeed2
15021502 {
1503- get => FileMarkSettings . Version >= VERSION_516
1504- ? SpeedConverter . Convert ( ExtraSettings . LiftSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1503+ get => FileMarkSettings . Version >= VERSION_516
1504+ ? SpeedConverter . Convert ( ExtraSettings . LiftSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
15051505 : 0 ;
15061506 set
15071507 {
@@ -1514,8 +1514,8 @@ public override float LiftSpeed2
15141514
15151515 public override float BottomRetractSpeed
15161516 {
1517- get => FileMarkSettings . Version >= VERSION_516
1518- ? SpeedConverter . Convert ( ExtraSettings . BottomRetractSpeed1 , FormatSpeedUnit , CoreSpeedUnit )
1517+ get => FileMarkSettings . Version >= VERSION_516
1518+ ? SpeedConverter . Convert ( ExtraSettings . BottomRetractSpeed1 , FormatSpeedUnit , CoreSpeedUnit )
15191519 : RetractSpeed ;
15201520 set
15211521 {
@@ -1528,8 +1528,8 @@ public override float BottomRetractSpeed
15281528
15291529 public override float RetractSpeed
15301530 {
1531- get => SpeedConverter . Convert ( FileMarkSettings . Version >= VERSION_516
1532- ? ExtraSettings . RetractSpeed1
1531+ get => SpeedConverter . Convert ( FileMarkSettings . Version >= VERSION_516
1532+ ? ExtraSettings . RetractSpeed1
15331533 : HeaderSettings . RetractSpeed , FormatSpeedUnit , CoreSpeedUnit ) ;
15341534 set
15351535 {
@@ -1542,7 +1542,7 @@ public override float RetractSpeed
15421542 public override float BottomRetractSpeed2
15431543 {
15441544 get => FileMarkSettings . Version >= VERSION_516
1545- ? SpeedConverter . Convert ( ExtraSettings . BottomRetractSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1545+ ? SpeedConverter . Convert ( ExtraSettings . BottomRetractSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
15461546 : 0 ;
15471547 set
15481548 {
@@ -1556,7 +1556,7 @@ public override float BottomRetractSpeed2
15561556 public override float RetractSpeed2
15571557 {
15581558 get => FileMarkSettings . Version >= VERSION_516
1559- ? SpeedConverter . Convert ( ExtraSettings . RetractSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1559+ ? SpeedConverter . Convert ( ExtraSettings . RetractSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
15601560 : 0 ;
15611561 set
15621562 {
@@ -1633,7 +1633,7 @@ public override string MachineName
16331633 }
16341634 set => base . MachineName = MachineSettings . MachineName = value ;
16351635 }
1636-
1636+
16371637 public override object [ ] Configs
16381638 {
16391639 get
@@ -1651,7 +1651,7 @@ public override object[] Configs
16511651 return new object [ ]
16521652 {
16531653 FileMarkSettings , HeaderSettings , PreviewSettings , LayerImageColorSettings , LayersDefinition ,
1654- ExtraSettings , MachineSettings
1654+ ExtraSettings , MachineSettings
16551655 } ;
16561656 case VERSION_517 :
16571657 return new object [ ]
@@ -1792,7 +1792,7 @@ public AnyCubicMachine PrinterModel
17921792
17931793 return AnyCubicMachine . PhotonS ;
17941794 }
1795- }
1795+ }
17961796 #endregion
17971797
17981798 #region Constructors
@@ -1878,16 +1878,18 @@ protected override void EncodeInternally(OperationProgress progress)
18781878 if ( LayerImageColorSettings . GreyMaxCount < 16 || LayerImageColorSettings . Grey . Length < 16 )
18791879 {
18801880 LayerImageColorSettings . GreyMaxCount = 16 ;
1881- LayerImageColorSettings . Grey = new byte [ 16 ] ;
18821881 }
1883-
1882+
18841883 // But if the AntiAliasing is higher than 16, we adjust the table (Experimental)
18851884 if ( HeaderSettings . AntiAliasing > LayerImageColorSettings . GreyMaxCount || HeaderSettings . AntiAliasing > LayerImageColorSettings . Grey . Length )
18861885 {
18871886 LayerImageColorSettings . GreyMaxCount = HeaderSettings . AntiAliasing ;
1888- LayerImageColorSettings . Grey = new byte [ HeaderSettings . AntiAliasing ] ;
18891887 }
18901888
1889+ // Ensure the table is the correct size
1890+ if ( LayerImageColorSettings . Grey . Length != LayerImageColorSettings . GreyMaxCount )
1891+ LayerImageColorSettings . Grey = new byte [ LayerImageColorSettings . GreyMaxCount ] ;
1892+
18911893 // Map the grey values
18921894 for ( var i = 0 ; i < LayerImageColorSettings . GreyMaxCount ; i ++ )
18931895 {
@@ -1906,7 +1908,7 @@ protected override void EncodeInternally(OperationProgress progress)
19061908 FileMarkSettings . LayerImageAddress = FileMarkSettings . LayerDefinitionAddress + LayersDefinition . TableLength + AnycubicNamedTable . TableBaseLength ;
19071909
19081910 outputFile . Seek ( FileMarkSettings . LayerImageAddress , SeekOrigin . Begin ) ;
1909-
1911+
19101912 if ( Version >= VERSION_516 )
19111913 {
19121914 FileMarkSettings . ExtraAddress = FileMarkSettings . LayerImageAddress ;
@@ -1984,7 +1986,7 @@ protected override void EncodeInternally(OperationProgress progress)
19841986
19851987
19861988 //layersHash.Add(hash, layerDef);
1987-
1989+
19881990 outputFile . WriteBytes ( layerDef . EncodedRle ) ;
19891991 layerDef . EncodedRle = null ! ;
19901992 //}
@@ -2074,7 +2076,7 @@ protected override void DecodeInternally(OperationProgress progress)
20742076 ExtraSettings . BottomLiftSpeed2 = HeaderSettings . LiftSpeed ;
20752077 ExtraSettings . BottomRetractSpeed1 = HeaderSettings . RetractSpeed ;
20762078 ExtraSettings . BottomRetractSpeed2 = HeaderSettings . RetractSpeed ;
2077-
2079+
20782080 ExtraSettings . LiftHeight1 = HeaderSettings . LiftHeight ;
20792081 ExtraSettings . LiftSpeed1 = HeaderSettings . LiftSpeed ;
20802082 ExtraSettings . LiftHeight2 = 0 ;
@@ -2148,9 +2150,9 @@ protected override void DecodeInternally(OperationProgress progress)
21482150 Debug . Write ( "LayersDefinition -> " ) ;
21492151 Debug . WriteLine ( LayersDefinition ) ;
21502152 LayersDefinition . Validate ( ) ;
2151-
2153+
21522154 Init ( LayersDefinition . LayerCount , DecodeType == FileDecodeType . Partial ) ;
2153-
2155+
21542156 progress . Reset ( OperationProgress . StatusDecodeLayers , LayerCount ) ;
21552157 foreach ( var batch in BatchLayersIndexes ( ) )
21562158 {
0 commit comments