我正在使用來自C#應用程序的GnuPlot。我想直接從標準輸出讀取GnuPlot PNG輸出,而不是保存到文件然後閱讀。我的代碼看起來像現在這種權利:在C#中讀取GnuPlot輸出到圖像中#
string Path = @"C:\Program Files\gnuplot\bin\gnuplot.exe";
Process GnuplotProcess = new Process();
GnuplotProcess.StartInfo.FileName = Path;
GnuplotProcess.StartInfo.UseShellExecute = false;
GnuplotProcess.StartInfo.RedirectStandardInput = true;
GnuplotProcess.StartInfo.RedirectStandardOutput = true;
GnuplotProcess.Start();
StreamWriter SW = GnuplotProcess.StandardInput;
StreamReader SR = GnuplotProcess.StandardOutput;
SW.WriteLine("set terminal pngcairo size 300,200");
foreach (LoadCaseOutput LCO in LoadCases)
{
foreach (LoadCaseOutput.MemberOutput MO in LCO.Members)
{
SW.WriteLine("plot " + MO.GenerateAFEquation(P));
MO.AFImage = Image.FromStream(SR.BaseStream);
}
}
SW.WriteLine("exit");
GnuplotProcess.Close();
眼下這似乎在Image.FromStream()線來搪塞。出了什麼問題?
我猜GnuPlot StandardOutput實際上是不輸出圖像。如果將SR.BaseStream重定向到文件會發生什麼情況。你能把它看作一個圖像嗎?根據MSDN,隱含的消息是StandardOutput是文本。 – tatmanblue
如果是停頓是因爲文件結尾沒有被髮送信號。 – Marco