LEADTOOLS Support
General
LEADTOOLS SDK Examples
HOW TO: Get RasterImage from UWP SoftwareBitmap
#1
Posted
:
Monday, March 18, 2019 3:26:31 PM(UTC)
Groups: Manager, Tech Support, Administrators
Posts: 218
Was thanked: 12 time(s) in 12 post(s)
Here is a method that will return a RasterImage from a SoftwareBitmap:
Code:
public async Task<RasterImage> RasterImageFromSoftwareBitmap(SoftwareBitmap softwareBitmap)
{
byte[] array = null;
using (var ms = new InMemoryRandomAccessStream())
{
BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, ms);
encoder.SetSoftwareBitmap(softwareBitmap);
await encoder.FlushAsync();
array = new byte[ms.Size];
await ms.ReadAsync(array.AsBuffer(), (uint)ms.Size, InputStreamOptions.None);
using (RasterCodecs codecs = new RasterCodecs())
{
var s = ms.AsStream();
s.Position = 0;
RasterImage img = codecs.Load(s);
return img;
}
}
}
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
LEADTOOLS Support
General
LEADTOOLS SDK Examples
HOW TO: Get RasterImage from UWP SoftwareBitmap
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.