using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Text; using ZXing; namespace AllBase { public class ImageErWeiMa { /// /// 是否二维码 /// /// /// public bool GetErWeiMa(byte[] file, out int width, out int height, out Image initImage) { initImage = null; width = 0; height = 0; try { MemoryStream ms = new MemoryStream(file); initImage = Image.FromStream(ms); ms.Close(); width = initImage.Width; height = initImage.Height; if (initImage.Width < 10 || initImage.Height < 10) { initImage = null; return false; } BarcodeReader reader = new BarcodeReader(); Result result = reader.Decode((Bitmap)initImage); if (result == null || string.IsNullOrEmpty(result.Text)) { reader = null; result = null; //initImage = null; return false; } reader = null; result = null; initImage = null; } catch { return false; } return true; } } }