I am traying to make video player. I want draw images with sharpdx sdk because of cpu isue. But I have an isue. I am getting frames as byte array. Pixel format of images are BGRA32. I wrote following code to convert it. But it gives to me error "Value does not fall within the expected range".
My code is :
private Bitmap getBitmap(byte[] frame) {
return RenderTarget.CreateBitmap(new SizeU((uint)img_w, (uint)img_h), frame, 0, new BitmapProperties(new PixelFormat(DxgiFormat.B8G8R8A8_UNORM, AlphaMode.Ignore), 100, 100));
}
Note : img_w = 720, img_h = 576, length of frame array = 720 * 576 * 4
I tried that first of all create image than copy data to image. But it doesn't work also. It copies first row to all row.
Left image is original image, right is created by copy from byte array . I used following code to create this image.
private Bitmap getBitmap(byte[] frame) {
var bmp = RenderTarget.CreateBitmap(new SizeU((uint)img_w, (uint)img_h), IntPtr.Zero, 0, new BitmapProperties(new PixelFormat(DxgiFormat.B8G8R8A8_UNORM, AlphaMode.Ignore), 100, 100));
bmp.CopyFromMemory(new RectU(0, 0, (uint)img_w, (uint)img_h), frame, 0);
return bmp;
}