Converting as image file from SIPSorceryMedia.Abstractions.RawImage to Avalonia.Media.Imaging.Bitmap #9328
Replies: 8 comments
-
What is the value of |
Beta Was this translation helpful? Give feedback.
-
SIPSorceryMedia.Abstractions.VideoPixelFormatsEnum.Rgb public enum VideoPixelFormatsEnum public class RawImage public int Width { get; set; } public byte[] GetBuffer (); |
Beta Was this translation helpful? Give feedback.
-
I have converted SIPSorceryMedia.Abstractions.RawImage rawImage to System.Drawing.Bitmap with the following code: Bitmap bitmap = new Bitmap(rawImage.Width, rawImage.Height, rawImage.Stride, PixelFormat.Format24bppRgb, rawImage.Sample); After that converted this to Avalonia.Media.Imaging.Bitmap with the following code: System.Drawing.Bitmap bitmapTmp = new System.Drawing.Bitmap(bitmap); AND it is working in Windows platform. To work in cross-platform (Win, Linux, OSX), I want to convert SIPSorceryMedia.Abstractions.RawImage rawImage to Avalonia.Media.Imaging.Bitmap directly. Any help in this regards? |
Beta Was this translation helpful? Give feedback.
-
Try to create it with WriteableBitmap by copying pixel data to the locked buffer. Like here https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls.ColorPicker/Helpers/ColorPickerHelpers.cs#L606-L627 |
Beta Was this translation helpful? Give feedback.
-
Also, important to find out correct PixelFormat that RawImage is using, by converting VideoPixelFormatsEnum I assume. |
Beta Was this translation helpful? Give feedback.
-
"Also, important to find out correct PixelFormat that RawImage is using, by converting VideoPixelFormatsEnum I assume." I think here I am stuck. Need more help in this regards. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, I don't have experience with this library. |
Beta Was this translation helpful? Give feedback.
-
Converted this into Q&A as this is neither a bug nor a feature request. If you disagree please let us know. |
Beta Was this translation helpful? Give feedback.
-
I am using SIPSorceryMedia.FFmpeg (https://github.com/sipsorcery-org/SIPSorceryMedia.FFmpeg) in one of my project. They exposed video frame as SIPSorceryMedia.Abstractions.RawImage. Becuase System.Drawing.Image is not a cross platform.
Now I want to convert SIPSorceryMedia.Abstractions.RawImage to Avalonia.Media.Imaging.Bitmap. So that I can display the image in Avalonia App. I have tried this way:
Bitmap avalonia_bitmap = new Bitmap(Avalonia.Platform.PixelFormat.Rgb565, Avalonia.Platform.AlphaFormat.Premul,
rawImage.Sample,
new Avalonia.PixelSize(rawImage.Width, rawImage.Height),
new Avalonia.Vector(96, 96),
rawImage.Stride);
but no luck.
If I change Avalonia.Platform.PixelFormat.Bgra8888 or Avalonia.Platform.PixelFormat.Rgba8888, getting error 'Unable to create bitmap from provided data'
Any help in this regards. [https://github.com/sipsorcery-org/SIPSorceryMedia.FFmpeg/issues/45]
Beta Was this translation helpful? Give feedback.
All reactions