gpt4 book ai didi

C# 将位图转换为 FFmediaToolkits ImageData

转载 作者:行者123 更新时间:2023-12-04 23:11:18 26 4
gpt4 key购买 nike

我有标准 System.Drawing.Bitmap我需要将其转换为 FFMediaToolkit.Graphics.ImageData .我怎样才能做到这一点?
我试过了:

ImageData.FromArray((byte[]) converter.ConvertTo(frame, typeof(byte[])),
ImagePixelFormat.Argb32, frame.Width,frame.Height)
但它确实给了我这个错误:
Unhandled exception. System.ArgumentException: Pixel buffer size doesn't match size required by this image format.
谢谢你的帮助

最佳答案

解决方案是:

private static ImageData FrameToImageData(Bitmap bitmap) 
{
Rectangle rect = new Rectangle(System.Drawing.Point.Empty, bitmap.Size);
BitmapData bitLock = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
ImageData bitmapImageData = ImageData.FromPointer(bitLock.Scan0, ImagePixelFormat.Bgr24, bitmap.Size);
bitmap.UnlockBits(bitLock);
return bitmapImageData;
}

关于C# 将位图转换为 FFmediaToolkits ImageData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67408503/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com