-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adaptations in samples to work correctly with Orbbec Femto Bolt devic…
…es via OrbbecSDK-K4A-Wrapper.
- Loading branch information
Showing
11 changed files
with
207 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using K4AdotNet.Sensor; | ||
using SixLabors.ImageSharp.Formats; | ||
using SixLabors.ImageSharp.Formats.Jpeg; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
||
namespace K4AdotNet.Samples.Wpf.Common | ||
{ | ||
/// <summary>Helper methods to work with images.</summary> | ||
public static class ImageConverters | ||
{ | ||
private static readonly DecoderOptions decoderOptions = new(); | ||
|
||
/// <summary>Decodes MJPEG image to the destination BGRA image buffer.</summary> | ||
/// <param name="mjpegImage">Source image in MJPEG format to be decoded. Not <see langword="null"/>.</param> | ||
/// <param name="dstBuffer">Destination buffer for a decoded image. Should be big enough for a result BGRA image (4 bytes per pixel). Not <see langword="null"/>.</param> | ||
public static unsafe void DecodeMjpegToBgra(Image mjpegImage, byte[] dstBuffer) | ||
{ | ||
Debug.Assert(mjpegImage.Format == ImageFormat.ColorMjpg); | ||
|
||
using var stream = new UnmanagedMemoryStream((byte*)mjpegImage.Buffer.ToPointer(), mjpegImage.SizeBytes); | ||
using var decodedImage = JpegDecoder.Instance.Decode<Bgra32>(decoderOptions, stream); | ||
decodedImage.CopyPixelDataTo(dstBuffer); | ||
} | ||
} | ||
} |
Oops, something went wrong.