Skip to content

Commit df0da21

Browse files
committed
Updating readme
1 parent 2f76997 commit df0da21

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

README.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ KGy SOFT Drawing Libraries offer advanced bitmap data manipulation and image pro
2121
- [Icon Manipulation](#icon-manipulation)
2222
- [Fast Bitmap Manipulation](#fast-bitmap-manipulation)
2323
- [Managed Bitmap Data Manipulation](#managed-bitmap-data-manipulation)
24-
- [WriteableBitmap and Other 3rd Party Bitmap Types Support](#writeablebitmap-and-other-3rd-party-bitmap-types-support)
24+
- [3rd Party Bitmap Types Support](#3rd-party-bitmap-types-support)
2525
- [Supporting Custom Pixel Formats](#supporting-custom-pixel-formats)
2626
- [Quantizing and Dithering](#quantizing-and-dithering)
2727
- [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
102102

103103
<p align="center">
104104
<a href="Examples/Maui"><img alt="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 <a href="Examples">Examples</a> folder for all of the example applications.</em>
106107
</p>
107108

108109
#### KGy SOFT Imaging Tools and Debugger Visualizers:
@@ -143,6 +144,7 @@ Starting with version 7.0.0 each packages have their own change logs:
143144
## Examples
144145

145146
### Icon Manipulation
147+
<sub>(Requires the [KGySoft.Drawing](https://www.nuget.org/packages/KGySoft.Drawing) package for the GDI+ `Icon` type)</sub>
146148

147149
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.
148150

@@ -157,6 +159,7 @@ Icon combined = myIcon.Combine(bmp);
157159
> 💡 _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.
158160
159161
### 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>
160163

161164
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.
162165

@@ -197,13 +200,14 @@ Not only for the native `Bitmap` type can you obtain a managed accessor (as desc
197200

198201
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.
199202

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>
201205

202206
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.
203207

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:
205209

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.
207211
208212
```cs
209213
// Though naming is different, PixelFormats.Pbgra32 is the same as KnownPixelFormat.Format32bppPArgb.
@@ -225,11 +229,12 @@ bitmap.Unlock();
225229
```
226230

227231
### Supporting Custom Pixel Formats
232+
<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>
228233
229234
The previous example demonstrated how we can create a managed accessor for a `WriteableBitmap`. But it worked only because we used a pixel format that happen to have built-in support also in KGy SOFT Drawing Libraries. In fact, the libraries provide support for any custom pixel format. 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:
230235
231236
```cs
232-
// Gray8 format has no built-in support
237+
// Gray8 format has no built-in support in KGySoft.Drawing.Core
233238
var bitmap = new WriteableBitmap(width, height, dpiX, dpiY, PixelFormats.Gray8, null);
234239

235240
// But we can specify how to use it
@@ -250,6 +255,8 @@ return BitmapDataFactory.CreateBitmapData(
250255
});
251256
```
252257

258+
> 💡 _Tip:_ See also the [Xamarin](Examples/Xamarin) and [MAUI](Examples/Maui) examples that demonstrate [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.
259+
253260
Note that there are different overloads for indexed formats where you have to specify how to read/write a palette index. Please also note that these delegates work with 32-bit color structures (just like usual `GetPixel`/`SetPixel`) so wider formats will be quantized into the ARGB8888 color space (or BGRA8888, using the alternative terminology) when getting/setting pixels but this is how regular formats work, too. Anyway, you can always access the actual underlying data of whatever format by the aforementioned [`IReadableBitmapDataRow.ReadRaw`](https://docs.kgysoft.net/drawing/html/M_KGySoft_Drawing_Imaging_IReadableBitmapDataRow_ReadRaw__1.htm) and [`IWritableBitmapDataRow.WriteRaw`](https://docs.kgysoft.net/drawing/html/M_KGySoft_Drawing_Imaging_IWritableBitmapDataRow_WriteRaw__1.htm) methods.
254261
255262
### Quantizing and Dithering

0 commit comments

Comments
 (0)