【发布时间】:2016-07-11 16:34:26
【问题描述】:
在 WPF 中工作并尝试从头开始创建 BitmapSource。以下代码给出了一个参数异常“值不在预期范围内”。我不知道为什么。我还是 WPF 的新手,也许我没有正确使用像素格式?
int width = 12;
int height = 14;
byte[] colorData = new byte[width * height * 4];
for(int i = 0; i < colorData.Length; i++)
{
colorData[i] = 155; //create all pixels same shade of gray
}
BitmapSource bitmap = BitmapSource.Create(width, height, 96, 96, PixelFormats.Bgra32, null, colorData, width);
【问题讨论】:
标签: c# wpf bytearray bitmapsource