Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, March 18, 2019 3:31:31 PM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 197

Was thanked: 9 time(s) in 9 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.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

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.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.083 seconds.