You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `Bitmap` property has been replaced by `UnsafeBitmap` to make direct memory binding explicit.
All returns now provide a copy (`new Bitmap(UnsafeBitmap)`) to avoid memory leaks and side effects. Dispose logic and resource management have been improved.
Color conversion in `ColorHsv` is more robust (clamping instead of exceptions).
Methods return null if errors occur.
SIMD and pixel operations have been refactored. `Pixel32` is now immutable (`readonly`).
Tests and helper methods consistently use `UnsafeBitmap`. The changes increase security and efficiency in the imaging framework.
@@ -134,11 +134,14 @@ public DirectBitmap(string filePath)
134
134
135
135
/// <summary>
136
136
/// Gets the bitmap.
137
+
/// Be careful, we pass a reference that never gets copied, so any changes to this Bitmap will affect the DirectBitmap and vice versa.
138
+
/// GcHandle is pinned, so the memory address of the pixel data will not change, allowing for direct manipulation of the bitmap's pixels.
139
+
/// This memory is not managed by the .NET runtime, so it is crucial to ensure that it is properly released to avoid memory leaks. Always call Dispose() when done with the DirectBitmap to free the pinned handle and associated resources.
137
140
/// </summary>
138
141
/// <value>
139
142
/// The bitmap.
140
143
/// </value>
141
-
publicBitmapBitmap{get;privateset;}
144
+
publicBitmapUnsafeBitmap{get;privateset;}
142
145
143
146
/// <summary>
144
147
/// Gets a value indicating whether this <see cref="DirectBitmap" /> is disposed.
@@ -154,7 +157,12 @@ public DirectBitmap(string filePath)
154
157
/// <inheritdoc />
155
158
publicintWidth{get;}
156
159
157
-
/// <inheritdoc />
160
+
/// <summary>
161
+
/// Gets or sets the bits handle.
162
+
/// </summary>
163
+
/// <value>
164
+
/// The bits handle.
165
+
/// </value>
158
166
privateGCHandleBitsHandle{get;set;}
159
167
160
168
/// <inheritdoc />
@@ -206,7 +214,7 @@ private void Initiate(Color color = default)
0 commit comments