diff --git a/OpenCvSharp.sln.DotSettings b/OpenCvSharp.sln.DotSettings
index 61d2cba2e..a9a9541ca 100644
--- a/OpenCvSharp.sln.DotSettings
+++ b/OpenCvSharp.sln.DotSettings
@@ -12,6 +12,11 @@
<Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
<Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
<Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
+ <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
+ <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy>
+ <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
+ <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
+ True
True
True
True
diff --git a/src/OpenCvSharp/Modules/core/Mat/Mat.cs b/src/OpenCvSharp/Modules/core/Mat/Mat.cs
index 86ccb9435..4034352d0 100644
--- a/src/OpenCvSharp/Modules/core/Mat/Mat.cs
+++ b/src/OpenCvSharp/Modules/core/Mat/Mat.cs
@@ -3694,8 +3694,11 @@ public byte[] ToBytes(string ext = ".png", params ImageEncodingParam[] prms)
///
///
///
- public MemoryStream ToMemoryStream(string ext = ".png", params ImageEncodingParam[] prms)
- => new (ToBytes(ext, prms));
+ public MemoryStream ToMemoryStream(string ext = ".png", params ImageEncodingParam[] prms)
+ {
+ var bytes = ToBytes(ext, prms);
+ return new MemoryStream(bytes, 0, bytes.Length, writable: false, publiclyVisible: true);
+ }
///
/// Writes image data encoded from this Mat to System.IO.Stream