大佬教程收集整理的这篇文章主要介绍了.net – 移动设备上的OutOfMemoryException,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
public static Bitmap TakePicture() { var dialog = new CameraCaptureDialog { Resolution = new Size(1600,1200),StillQuality = CameraCaptureStillQuality.Default }; dialog.ShowDialog(); // If the filename is empty the user took no picture if (String.IsNullOrEmpty(dialog.FileName)) return null; // (!) The OutOfMemoryException is thrown here (!) var bitmap = new Bitmap(dialog.FileName); File.delete(dialog.FileName); return bitmap; }
private void _pictureBox_Click(object sender,EventArgs E) { _takePictureLinkLabel.Visible = false; var image = Camera.TakePicture(); if (image == null) return; image = Camera.CutBitmap(image,2.5); _pictureBox.Image = image; _image = Camera.ImageToByteArray(imagE); }
同样地,你可能应该使用图像,但是再次:不确定我是否期望这是成败;值得一试,但……
public static Bitmap TakePicture() { String filename; using(var dialog = new CameraCaptureDialog { Resolution = new Size(1600,StillQuality = CameraCaptureStillQuality.Default }) { dialog.ShowDialog(); filename = dialog.Filename; } // If the filename is empty the user took no picture if (String.IsNullOrEmpty(fileName)) return null; // (!) The OutOfMemoryException is thrown here (!) var bitmap = new Bitmap(fileName); File.delete(fileName); return bitmap; } private void _pictureBox_Click(object sender,EventArgs E) { _takePictureLinkLabel.Visible = false; using(var image = Camera.TakePicture()) { if (image == null) return; image = Camera.CutBitmap(image,2.5); _pictureBox.Image = image; _image = Camera.ImageToByteArray(imagE); } }
我也会对CutBitmap等有点谨慎,以确保尽快发布.
以上是大佬教程为你收集整理的.net – 移动设备上的OutOfMemoryException全部内容,希望文章能够帮你解决.net – 移动设备上的OutOfMemoryException所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。