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
-[Quantizing and Dithering](#quantizing-and-dithering)
27
27
-[Advanced GIF Encoder with High Color Support](#advanced-gif-encoder-with-high-color-support)
@@ -102,7 +102,8 @@ See the [Examples](Examples) folder for example applications for using KGy SOFT
102
102
103
103
<palign="center">
104
104
<ahref="Examples/Maui"><imgalt="KGy SOFT Drawing MAUI Example App"src="https://user-images.githubusercontent.com/27336165/195989657-0e2fb0ba-4d2d-4de1-889b-d3f75b572895.png"/></a>
105
-
<br/><em>KGy SOFT Drawing MAUI Example App running on Android Phone.</em>
105
+
<br/><em>KGy SOFT Drawing MAUI Example App running on Android Phone.
106
+
<br/>See the <ahref="Examples">Examples</a> folder for all of the example applications.</em>
106
107
</p>
107
108
108
109
#### KGy SOFT Imaging Tools and Debugger Visualizers:
@@ -143,6 +144,7 @@ Starting with version 7.0.0 each packages have their own change logs:
143
144
## Examples
144
145
145
146
### Icon Manipulation
147
+
<sub>(Requires the [KGySoft.Drawing](https://www.nuget.org/packages/KGySoft.Drawing) package for the GDI+ `Icon` type)</sub>
146
148
147
149
Icon images of different resolutions and color depth can be extracted from an `Icon`, whereas `Bitmap` and `Icon` instances can be combined into a new `Icon`. PNG compressed icons are also supported.
> 💡 _Tip:_ See more details at the [Icons](https://docs.kgysoft.net/drawing/html/T_KGySoft_Drawing_Icons.htm) and [IconExtensions](https://docs.kgysoft.net/drawing/html/T_KGySoft_Drawing_IconExtensions.htm) classes.
158
160
159
161
### Fast Bitmap Manipulation
162
+
<sub>(This example requires the [KGySoft.Drawing](https://www.nuget.org/packages/KGySoft.Drawing) package for the GDI+ `Bitmap` type but works similarly also for bitmaps of other frameworks you can create an [`IBitmapData`](https://docs.kgysoft.net/drawing/html/T_KGySoft_Drawing_Imaging_IBitmapData.htm) instance for.)</sub>
160
163
161
164
As it is well known, `Bitmap.SetPixel`/`GetPixel` methods are very slow. Additionally, they do not support every pixel format. A typical solution can be to obtain a `BitmapData` by the `LockBits` method, which has further drawbacks: you need to use unsafe code and pointers, and the way you need to access the bitmap data depends on the actual `PixelFormat` of the bitmap.
162
165
@@ -197,13 +200,14 @@ Not only for the native `Bitmap` type can you obtain a managed accessor (as desc
197
200
198
201
The [`BitmapDataFactory`](https://docs.kgysoft.net/drawing/html/T_KGySoft_Drawing_Imaging_BitmapDataFactory.htm) class has many [`CreateBitmapData`](https://docs.kgysoft.net/drawing/html/Overload_KGySoft_Drawing_Imaging_BitmapDataFactory_CreateBitmapData.htm) overloads. The ones whose first parameter is `Size` allocate the underlying buffer by themselves, which is not directly accessible from outside. But you are also able to use predefined arrays of any primitive element type (one or two dimensional ones), and also [`ArraySection<T>`](https://docs.kgysoft.net/corelibraries/html/T_KGySoft_Collections_ArraySection_1.htm) or [`Array2D<T>`](https://docs.kgysoft.net/corelibraries/html/T_KGySoft_Collections_Array2D_1.htm) buffers to create a managed bitmap data for.
199
202
200
-
### WriteableBitmap and Other 3rd Party Bitmap Types Support
203
+
### 3rd Party Bitmap Types Support
204
+
<sup>(This example requires the [KGySoft.Drawing.Core](https://www.nuget.org/packages/KGySoft.Drawing.Core) package and WPF. Actually you can simply use the [KGySoft.Drawing.Wpf](https://www.nuget.org/packages/KGySoft.Drawing.Wpf) package for WPF.)</sup>
201
205
202
206
The [`BitmapDataFactory`](https://docs.kgysoft.net/drawing/html/T_KGySoft_Drawing_Imaging_BitmapDataFactory.htm) class has also [`CreateBitmapData`](https://docs.kgysoft.net/drawing/html/Overload_KGySoft_Drawing_Imaging_BitmapDataFactory_CreateBitmapData.htm) overloads to support unmanaged memory. This makes possible to support any bitmap representation that exposes its buffer by a pointer.
203
207
204
-
For example, this is how you can create a managed accessor for a `WriteableBitmap` instance commonly used in WPF/WinRT/UWP and other XAML-based environments, which expose such a pointer:
208
+
For example, this is how you can create a managed accessor for a `WriteableBitmap` instance commonly used in WPF/WinRT/UWP and other XAML-based environments, which expose such a pointer or stream:
205
209
206
-
> 💡 _Tip:_ In fact, if you use the `WriteableBitmap`for WPF, then you can simply use the [`GetReadWriteBitmapData`](https://docs.kgysoft.net/drawing/html/M_KGySoft_Drawing_Wpf_WriteableBitmapExtensions_GetReadWriteBitmapData.htm)extension from the `KGySoft.Drawing.Wpf`package. But this is how you can access a `WriteableBitmap` of other XAML-based environments that do not have direct support yet.
210
+
> 💡 _Tip:_ In fact, if you use the `WriteableBitmap`of WPF/UWP/WinUI platforms, then you can simply use the [`GetReadWriteBitmapData`](https://docs.kgysoft.net/drawing/html/M_KGySoft_Drawing_Wpf_WriteableBitmapExtensions_GetReadWriteBitmapData.htm)extensions from their corresponding [package](#available-packages). But this is how you can turn a bitmap of any environment into a managed bitmap data that does not have direct support yet.
207
211
208
212
```cs
209
213
// Though naming is different, PixelFormats.Pbgra32 is the same as KnownPixelFormat.Format32bppPArgb.
@@ -225,11 +229,12 @@ bitmap.Unlock();
225
229
```
226
230
227
231
### Supporting Custom Pixel Formats
232
+
<sup>(Thisexamplerequiresthe [KGySoft.Drawing.Core](https://www.nuget.org/packages/KGySoft.Drawing.Core) package and WPF. Actually you can simply use the [KGySoft.Drawing.Wpf](https://www.nuget.org/packages/KGySoft.Drawing.Wpf) package for WPF.)</sup>
228
233
229
234
Thepreviousexampledemonstratedhowwecancreateamanagedaccessorfora `WriteableBitmap`. Butitworkedonlybecauseweusedapixelformatthathappentohavebuilt-insupportalsoinKGySOFTDrawingLibraries. Infact, thelibrariesprovidesupportforanycustompixelformat. The [`CreateBitmapData`](https://docs.kgysoft.net/drawing/html/Overload_KGySoft_Drawing_Imaging_BitmapDataFactory_CreateBitmapData.htm) methods have several overloads that allow you to specify a custom pixel format along with a couple of delegates to be called when pixels are read or written:
230
235
231
236
```cs
232
-
// Gray8 format has no built-in support
237
+
// Gray8 format has no built-in support in KGySoft.Drawing.Core
> 💡 _Tip:_Seealsothe [Xamarin](Examples/Xamarin) and [MAUI](Examples/Maui) examplesthatdemonstrate [how](https://github.com/koszeggy/KGySoft.Drawing/blob/2f769973dff4c702dd496873f77ddcc4e728a994/Examples/Maui/Extensions/SKBitmapExtensions.cs#L99) to create a bitmap data for SkiaSharp's `SKBitmap` type.
0 commit comments