问题描述
变量 inputFile 保持为空,因为 fileOpenPicker 由于某种原因没有执行,这个函数过去工作得很好,它打开了一个文件资源管理器,让我选择了一个我不知道是什么让它像那样的图像
public async void Initiate_Matrix()
{
FileOpenPicker fileOpenPicker = new FileOpenPicker
{
SuggestedStartLocation = PickerLocationId.PicturesLibrary
};
fileOpenPicker.FileTypeFilter.Add(".tif");
var inputFile = await fileOpenPicker.PickSingleFileAsync();
if (inputFile == null)
{
// The user cancelled the picking operation
return;
}
using (IRandomAccessStream stream = await inputFile.OpenAsync(FileAccessMode.Read))
{
// Create the decoder from the stream
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);
PixelDataProvider pixelData = await decoder.GetPixelDataAsync();
var bytes = pixelData.DetachPixelData();
var a = decoder.PixelWidth;
var b = decoder.PixelHeight;
Color[,] array = new Color[a,b];
for (int x = 0; x < decoder.PixelWidth; x++)
{
for (int y = 0; y < decoder.PixelHeight; y++)
{
var location = (y * (int)decoder.PixelWidth + x) * 3;
Color color = Color.FromArgb(0,bytes[location + 0],bytes[location + 1],bytes[location + 2]);
array[x,y] = color;
}
}
matrix = array;
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)