diff --git a/Source/SharpDX.MediaFoundation/VideoFormatGuids.cs b/Source/SharpDX.MediaFoundation/VideoFormatGuids.cs
index 385a8241d..146800165 100644
--- a/Source/SharpDX.MediaFoundation/VideoFormatGuids.cs
+++ b/Source/SharpDX.MediaFoundation/VideoFormatGuids.cs
@@ -15,7 +15,7 @@ public static partial class VideoFormatGuids
/// Media foundation unique ID
public static Guid FromFourCC(SharpDX.Multimedia.FourCC fourCC)
{
- return new Guid(string.Concat(fourCC.ToString(), "-0000-0010-8000-00aa00389b71"));
+ return new Guid(string.Concat(fourCC.ToString("I", null), "-0000-0010-8000-00aa00389b71"));
}
}
}
diff --git a/Source/SharpDX/Multimedia/FourCC.cs b/Source/SharpDX/Multimedia/FourCC.cs
index ad7b2a16c..7a16802c2 100644
--- a/Source/SharpDX/Multimedia/FourCC.cs
+++ b/Source/SharpDX/Multimedia/FourCC.cs
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
+using System.Globalization;
using System.Runtime.InteropServices;
namespace SharpDX.Multimedia
@@ -26,7 +27,7 @@ namespace SharpDX.Multimedia
/// A FourCC descriptor.
///
[StructLayout(LayoutKind.Sequential, Size = 4)]
- public struct FourCC : IEquatable
+ public struct FourCC : IEquatable, IFormattable
{
///
/// Empty FourCC.
@@ -175,6 +176,48 @@ public override int GetHashCode()
return (int) value;
}
+ ///
+ /// Provides a custom string representation of the FourCC descriptor.
+ ///
+ ///
+ /// The general format "G" is equivalent to the parameterless.
+ /// . The special format "I" returns a
+ /// string representation which can be used to construct a Media
+ /// Foundation format GUID. It is equivalent to "X08".
+ ///
+ /// The format descriptor, which can be "G" (empty
+ /// or null is equivalent to "G"), "I" or any valid standard
+ /// number format.
+ /// The format provider for formatting
+ /// numbers.
+ /// The requested string representation.
+ /// In case of
+ /// is not "G", "I" or a valid number
+ /// format.
+ public string ToString(string format, IFormatProvider formatProvider)
+ {
+ if (string.IsNullOrEmpty(format))
+ {
+ format = "G";
+ }
+ if (formatProvider == null)
+ {
+ formatProvider = CultureInfo.CurrentCulture;
+ }
+
+ switch (format.ToUpperInvariant())
+ {
+ case "G":
+ return this.ToString();
+
+ case "I":
+ return this.value.ToString("X08", formatProvider);
+
+ default:
+ return this.value.ToString(format, formatProvider);
+ }
+ }
+
public static bool operator ==(FourCC left, FourCC right)
{
return left.Equals(right);