C# 使用佳能EDSDK Api的.Net 4.0 WPF应用程序遇到大量内存不足错误
我的Net 4.0 Wpf photo booth应用程序使用佳能EDSDK Api,由于不断出现内存不足错误,该应用程序已逐渐无法使用,例如: System.OutOfMemoryException:内存不足。在 System.Drawing.Image.FromStream(Stream-Stream,布尔值 使用EmbeddedColorManagement,Boolean validateImageData) 当应用程序捕获图像并将其从相机下载到计算机,然后尝试将图像裁剪到特定尺寸时,会发生很多情况 以下是最频繁发生崩溃的地方:C# 使用佳能EDSDK Api的.Net 4.0 WPF应用程序遇到大量内存不足错误,c#,wpf,out-of-memory,canon-sdk,C#,Wpf,Out Of Memory,Canon Sdk,我的Net 4.0 Wpf photo booth应用程序使用佳能EDSDK Api,由于不断出现内存不足错误,该应用程序已逐渐无法使用,例如: System.OutOfMemoryException:内存不足。在 System.Drawing.Image.FromStream(Stream-Stream,布尔值 使用EmbeddedColorManagement,Boolean validateImageData) 当应用程序捕获图像并将其从相机下载到计算机,然后尝试将图像裁剪到特定尺寸时,会
private void MainCamera_DownloadReady(EOSDigital.API.Camera sender, EOSDigital.API.DownloadInfo Info)
{
try
{
Info.FileName = "CamPic.jpg";
string dir = AppDomain.CurrentDomain.BaseDirectory;
sender.DownloadFile(Info, dir); //Download image from camera to PC
//Crop image to specific dimensions
Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
PhotoObject ph;
using (ImageFactory imf = new ImageFactory())
{
imf.Load(AppDomain.CurrentDomain.BaseDirectory + @"\CamPic.jpg");
if (((WebcamImageVM)DataContext).IsPortrait)
{
imf.Crop(new System.Drawing.Rectangle(600, 0, 720, 1080));
ph = new PhotoObject(WebcamImageVM.GetBitmapSource(new Bitmap(imf.Image)), true);
}
else
{
imf.Crop(new System.Drawing.Rectangle(150, 0, 1620, 1080));
ph = new PhotoObject(WebcamImageVM.GetBitmapSource(new Bitmap(imf.Image)), false);
}
}
}));
}
catch (Exception ex)
{
Logger.LogEvent(EventType.Error, "Failed to take photo with DSLR: " + ex.Message);
}
}
如果您有任何建议,我们将不胜感激您有什么问题?你想知道为什么会这样,在哪里。。。艾奇,是的,我想知道为什么会发生这种情况,以及应该采取什么措施来纠正这个问题