C#C
C#4y ago
97 replies
PurplePeopleEater

❔ Converting between various kinds of Bitmap objects without using Async code

Hi all,

I need help doing the following:

#1) Convert from an System.Drawing.Bitmap object to an Windows.Graphics.Imaging.SoftwareBitmap object without using asynchronous code (no "await" code, no "async" code, etc) and without needing to temporarily store the data on the filesystem as part of the process.

The image data always originates as an System.Drawing.Bitmap object that is created by taking a screenshot users' screen or a rectangular portion of a monitor.

I need to take that System.Drawing.Bitmap object and convert it to a Windows.Graphics.Imaging.SoftwareBitmap because I need to pass the image to a library that expects the image data to be a Windows.Graphics.Imaging.SoftwareBitmap. I do not have control over how that library works, I need to use it as-is.


#2) Convert from an Windows.Graphics.Imaging.SoftwareBitmap object to an System.Drawing.Bitmap object without using asynchronous code (no "await" code, no "async" code, etc) and without needing to temporarily store the data on the filesystem as part of the process.

I assume that I will need to be able to convert from an Windows.Graphics.Imaging.SoftwareBitmap object to an System.Drawing.Bitmap object because the System.Drawing.Bitmap object allows me to save it to the filesystem very easily while the Windows.Graphics.Imaging.SoftwareBitmap object does not allow saving to the filesystem easily. I want to store the Windows.Graphics.Imaging.SoftwareBitmap object on the filesystem as part of #3 below.
Was this page helpful?