The quick start guide familiarizes you with loading an image in Bitmap. You begin with creating a UWP application in Visual Studio, adding C1.UWP.Bitmap reference (dll), Image control, and a button to load an image from stream in C1Bitmap object.
To create a simple UWP application for loading an image in C1Bitmap object, follow these steps:
- Setting up the Application
- Loading an Image into C1Bitmap
The following image shows how the application displays an image loaded from a stream into C1Bitmap:

Setting up the Application
To set up the application, follow these steps:
- Create a new project and select Blank App (Universal Windows) in Visual Studio.
- Add the following references to the application.
- In the Solution Explorer, right click your project name and select Add | New Folder. Name the newly added folder. In our case, we have named the new folder as Resources.
- Add a sample image to the Resources folder and set its Build Action property to Embedded Resource from the Properties window.
- Add a standard Button control for loading a sample image and Image control, named img, for displaying the sample image.
- Set the Content property of the button as Load Image.
Back to Top
Loading an Image into C1Bitmap
To load the image in C1Bitmap, follow these steps:
- Switch to the code view and add the following import statements in the code.
Imports C1.Xaml.Bitmap
Imports System.Reflection
Imports Windows.Graphics.Imaging
using C1.Xaml.Bitmap;
using System.Reflection;
using System.Threading.Tasks;
using Windows.Graphics.Imaging;
using Windows.UI.Xaml.Media.Imaging;
- Create the following class objects.
Dim btmp As C1Bitmap
Dim sb As SoftwareBitmap
Dim sbs As SoftwareBitmapSource
C1Bitmap btmp;
SoftwareBitmap sb;
SoftwareBitmapSource sbs;
- Add the following code in the class constructor to initialize bitmap and SoftwareBitmapSource.
btmp = New C1Bitmap()
sbs = New SoftwareBitmapSource()
btmp = new C1Bitmap();
sbs = new SoftwareBitmapSource();
- Add the following code to the btnLoad_Click event to load the image in C1Bitmap using stream:
Dim asm As Assembly = GetType(MainPage).GetTypeInfo().Assembly
Using stream As Stream = asm.GetManifestResourceStream("BitmapUWP_VB.bitmap-sample.png")
btmp.Load(stream, New FormatConverter(PixelFormat.Format32bppPBGRA))
End Using
Await UpdateImageSource()
Assembly asm = typeof(MainPage).GetTypeInfo().Assembly;
using (Stream stream = asm.GetManifestResourceStream("BitmapUWP.Resources.bitmap-sample.png"))
{
btmp.Load(stream, new FormatConverter(PixelFormat.Format32bppPBGRA));
}
await UpdateImageSource();
Note: To call an asynchronous method on an event, we have used async keyword and await operator.
- Create a method, named UpdateImageSource, to create a SoftwareBitmap, set the source SoftwareBitmap and assign it to the image source:
Private Async Function UpdateImageSource() As Task
sb = btmp.ToSoftwareBitmap()
Await sbs.SetBitmapAsync(sb)
img.Source = sbs
End Function
private async Task UpdateImageSource()
{
sb = btmp.ToSoftwareBitmap();
await sbs.SetBitmapAsync(sb);
img.Source = sbs;
}
Back to Top