c# - BitmapSource.Create 错误 - 缓冲区大小不够大

标签 c# .net wpf

我有这个代码:

BitmapSource.Create(pixelWidth, pixelHeight,
                    dpiX, dpiY, image.Format, image.Palette,
                    _modifiedRgb, stride);

这是抛出一个

ArgumentException - The buffer size is not enough.

请问有什么想法吗?

最佳答案

这意味着您的 _modifiedRgb 不够大。
它需要包含 Height * Stride * Format.BitsPerPixel/8 字节。

关于c# - BitmapSource.Create 错误 - 缓冲区大小不够大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8492563/

相关文章:

c# - 我可以获取其他ElasticSearch索引设置吗?

c# - 看不到 NULL 终结符

c# - 如何绑定(bind)到 DynamicResource 以便可以使用 Converter 或 StringFormat 等? (修订版 4)

c# - 获取ListView中选中的Item的索引

c# - WPF- 验证错误事件不会触发

c# - 试图覆盖 ClaimsIdentityFactory 上的 CreateAsync 函数

c# - XmlSerializer 不显示对现有实例的更改

c# - 我可以不使用 try catch() 来忽略错误吗?

.net - .NET 4.5 中是否弃用了 ObjectContext?

c# - 以编程方式调用 SendTo