-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converting as image file from SIPSorceryMedia.Abstractions.RawImage to Avalonia.Media.Imaging.Bitmap #9071
Comments
What is the value of |
SIPSorceryMedia.Abstractions.VideoPixelFormatsEnum.Rgb public enum VideoPixelFormatsEnum public class RawImage public int Width { get; set; } public byte[] GetBuffer (); |
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? |
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 |
Also, important to find out correct PixelFormat that RawImage is using, by converting VideoPixelFormatsEnum I assume. |
"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. |
Unfortunately, I don't have experience with this library. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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]
The text was updated successfully, but these errors were encountered: