Skip to content

Commit

Permalink
Merge pull request #403 from drewnoakes/remove-custom-number-formatting
Browse files Browse the repository at this point in the history
Remove custom number formatting in ICC
  • Loading branch information
drewnoakes authored Feb 7, 2024
2 parents 0caa4d2 + da73fc5 commit 5482e10
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions MetadataExtractor/Formats/Icc/IccDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ private enum IccTagType
{
if (i != 0)
res.Append(", ");
res.Append(FormatDoubleAsString(reader.GetUInt16(12 + i * 2) / 65535.0, 7, false));
double value = reader.GetUInt16(12 + i * 2) / 65535.0;
res.AppendFormat("{0:0.0######}", value);
}
return res.ToString();
}
Expand All @@ -192,28 +193,6 @@ private enum IccTagType
}
}

private static string FormatDoubleAsString(double value, int precision, bool zeroes)
{
if (precision < 1)
return string.Empty + (long)Math.Round(value);

var intPart = Math.Abs((long)value);
long rest = (int)(long)Math.Round((Math.Abs(value) - intPart) * Math.Pow(10, precision));
var restKept = rest;
var res = string.Empty;
for (var i = precision; i > 0; i--)
{
var cour = unchecked((byte)Math.Abs(rest % 10));
rest /= 10;
if (res.Length > 0 || zeroes || cour != 0 || i == 1)
res = cour + res;
}

intPart += rest;
var isNegative = value < 0 && (intPart != 0 || restKept != 0);
return (isNegative ? "-" : string.Empty) + intPart + "." + res;
}

private string? GetRenderingIntentDescription()
{
return GetIndexedDescription(IccDirectory.TagRenderingIntent,
Expand Down

0 comments on commit 5482e10

Please sign in to comment.