Skip to content

Commit 877ee15

Browse files
authored
Merge pull request #391 from drewnoakes/back-compat
Address minor regressions
2 parents 06b0bd0 + 4d7253e commit 877ee15

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

MetadataExtractor/Formats/Exif/makernotes/OlympusCameraSettingsMakernoteDescriptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public sealed class OlympusCameraSettingsMakernoteDescriptor(OlympusCameraSettin
651651
if (Directory.GetObject(OlympusCameraSettingsMakernoteDirectory.TagGradation) is not short[] values || values.Length < 3)
652652
return null;
653653

654-
var ret = (values[0], values[1], values[3]) switch
654+
var ret = (values[0], values[1], values[2]) switch
655655
{
656656
(0, 0, 0) => "n/a",
657657
(-1, -1, 1) => "Low Key",

MetadataExtractor/Formats/QuickTime/QuickTimeReaderExtensions.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,33 @@ namespace MetadataExtractor.Formats.QuickTime
77
/// </summary>
88
public static class QuickTimeReaderExtensions
99
{
10+
#if NET462 || NETSTANDARD1_3
11+
public static unsafe string Get4ccString(this SequentialReader reader)
12+
#else
1013
public static string Get4ccString(this SequentialReader reader)
14+
#endif
1115
{
16+
// https://en.wikipedia.org/wiki/FourCC
17+
1218
Span<byte> bytes = stackalloc byte[4];
19+
Span<char> chars = stackalloc char[4];
1320

1421
reader.GetBytes(bytes);
1522

16-
return Encoding.ASCII.GetString(bytes);
23+
// NOTE we cannot just use Encoding.ASCII here, as that can replace certain non-printable characters with '?'
24+
chars[0] = (char)bytes[0];
25+
chars[1] = (char)bytes[1];
26+
chars[2] = (char)bytes[2];
27+
chars[3] = (char)bytes[3];
28+
29+
#if NET462 || NETSTANDARD1_3
30+
fixed (char* pChars = chars)
31+
{
32+
return new string(pChars, startIndex: 0, length: 4);
33+
}
34+
#else
35+
return new string(chars);
36+
#endif
1737
}
1838

1939
public static decimal Get16BitFixedPoint(this SequentialReader reader)

0 commit comments

Comments
 (0)