diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2024-09-02 06:41:16 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2024-09-02 06:41:16 +0300 |
| commit | b2b4196d6f3bb007ae250a3e0648d1a5786d8dbf (patch) | |
| tree | 7de10793cef1ad125febee72cbb29627461488dd /Software | |
| parent | 0d22d909e6263692d61709f1baf5dd6f0b34806e (diff) | |
| download | Tango-b2b4196d6f3bb007ae250a3e0648d1a5786d8dbf.tar.gz Tango-b2b4196d6f3bb007ae250a3e0648d1a5786d8dbf.zip | |
Implemented a workaround for light inks rounding.
Diffstat (limited to 'Software')
3 files changed, 63 insertions, 7 deletions
diff --git a/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs b/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs index 78339fe1d..43dc2e521 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs @@ -55,6 +55,39 @@ namespace Tango.ColorConversion NativePMR<ConversionInput, ConversionOutput> nativePMR = new NativePMR<ConversionInput, ConversionOutput>(convert); ConversionOutput output = nativePMR.Invoke(conversionInput); + if (conversionInput.UseLightInks) + { + try + { + InputLiquid cyan = conversionInput.InputCoordinates.InputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan); + OutputLiquid lightCyan = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.LightCyan); + + InputLiquid magenta = conversionInput.InputCoordinates.InputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta); + OutputLiquid lightMagenta = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.LightMagenta); + + InputLiquid yellow = conversionInput.InputCoordinates.InputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow); + OutputLiquid lightYellow = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.LightYellow); + + if (lightCyan != null && lightCyan.Volume > 0) + { + lightCyan.Volume = lightCyan.Volume.ReplaceDecimalPart(cyan.Volume); + } + if (lightMagenta != null && lightMagenta.Volume > 0) + { + lightMagenta.Volume = lightMagenta.Volume.ReplaceDecimalPart(magenta.Volume); + } + if (lightYellow != null && lightYellow.Volume > 0) + { + lightYellow.Volume = lightYellow.Volume.ReplaceDecimalPart(yellow.Volume); + } + } + catch (Exception) + { + LogManager.Default.Log("Error while correcting light inks decimal parts.", LogCategory.Error); + } + } + + bool result = NativeMethods.FreeLibrary(pDll); if (output.HasError) @@ -112,7 +145,7 @@ namespace Tango.ColorConversion conversionInput.InputCoordinates.L = stop.L; conversionInput.InputCoordinates.A = stop.A; conversionInput.InputCoordinates.B = stop.B; - if(conversionType == ConversionType.FineTuning) + if (conversionType == ConversionType.FineTuning) { conversionInput.InputCoordinates.Cyan = stop.Cyan; conversionInput.InputCoordinates.Magenta = stop.Magenta; @@ -120,7 +153,7 @@ namespace Tango.ColorConversion conversionInput.InputCoordinates.Key = stop.Black; } } - else if (stop.BrushColorSpace == ColorSpaces.CMYK ) + else if (stop.BrushColorSpace == ColorSpaces.CMYK) { conversionInput.InputCoordinates.Cyan = stop.Cyan; conversionInput.InputCoordinates.Magenta = stop.Magenta; @@ -343,7 +376,7 @@ namespace Tango.ColorConversion OutOfGamutInput input = new OutOfGamutInput(); input.ColorSpace = (PMR.ColorLab.ColorSpace)stop.BrushColorSpace; - + input.ThreadL = rml.WhitePointL; input.ThreadA = rml.WhitePointA; input.ThreadB = rml.WhitePointB; @@ -495,10 +528,10 @@ namespace Tango.ColorConversion return GetRecommendedProcessParametersByGamutRegion(job, group); } - return GetRecommendedProcessParameters( rml, job.Machine, stops, group, useLightInks ); + return GetRecommendedProcessParameters(rml, job.Machine, stops, group, useLightInks); } - public ProcessParametersTable GetRecommendedProcessParameters(Rml rml, Machine machine, List<BrushStop> stops, ProcessParametersTablesGroup group, bool useLightInks = false) + public ProcessParametersTable GetRecommendedProcessParameters(Rml rml, Machine machine, List<BrushStop> stops, ProcessParametersTablesGroup group, bool useLightInks = false) { var configuration = machine.Configuration; RecommendedProcessTableInput input = new RecommendedProcessTableInput(); @@ -567,7 +600,7 @@ namespace Tango.ColorConversion input.UseLightInks = settings.UseLightInks && rml.UseLightInks && machine.LightInksInstalled && useLightInks; input.UseLubricantTransform = rml.UseLubricantTransform; input.VMax = rml.VMax; - + //TODO: Do we need input.Vmax ?? (Mirta) foreach (var prTable in rml.GetActiveProcessGroup().ProcessParametersTables) diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DoubleExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DoubleExtensions.cs new file mode 100644 index 000000000..8ccab4d44 --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DoubleExtensions.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +public static class DoubleExtensions +{ + /// <summary> + /// Replaces the decimal part of this value and returns a new value. + /// </summary> + /// <param name="value">The value.</param> + /// <param name="fromValue">The value to take the decimal part from.</param> + /// <returns></returns> + public static double ReplaceDecimalPart(this double value, double fromValue) + { + decimal right = (decimal)fromValue - Math.Truncate((decimal)fromValue); + double result = (double)(Decimal.Truncate((decimal)value) + right); + return result; + } +} diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 9a55a25f9..71b17e014 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -104,6 +104,7 @@ <Compile Include="CustomAttributes\StringFormatAttribute.cs" /> <Compile Include="ExtensionMethods\BooleanExtensions.cs" /> <Compile Include="ExtensionMethods\ByteArrayExtensions.cs" /> + <Compile Include="ExtensionMethods\DoubleExtensions.cs" /> <Compile Include="ExtensionMethods\ListExtensions.cs" /> <Compile Include="ExtensionMethods\TimeSpanExtensions.cs" /> <Compile Include="ExtensionMethods\ZipArchiveExtensions.cs" /> @@ -221,7 +222,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> <Import Project="..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" /> |
