Ejemplo n.º 1
0
 public int Add(ClsPicture info)
 {
     if (!isRun)
     {
         return(-1);
     }
     queue.Add(info);
     return(0);
 }
Ejemplo n.º 2
0
        public void SavePic(ClsPicture pic)
        {
            //TODO 不存储图片
            return;

            string path = pic.picPath;

            //Global.LogServer.Add(new LogInfo("Debug", "PictureWork->SavePic picpath:" + path, (int)EnumLogLevel.DEBUG));
            //Regex.Replace(path, @"\", "\\");
            //Global.LogServer.Add(new LogInfo("Debug", "PictureWork->SavePic picpath:" + path + pic.picName, (int)EnumLogLevel.DEBUG));

            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
            }
            catch (System.Exception ex)
            {
                Global.LogServer.Add(new LogInfo("Error", "PictureWork->SavePic 查找创建图片路径失败:" + ex.Message, (int)EnumLogLevel.ERROR));
            }

            //string sPicDst = pic.picPath+pic.picName;
            // string sPicDst = "D:\\Image\\"+ pic.picName;
            //Global.LogServer.Add(new LogInfo("Debug", "PictureWork->SavePic picpath:" + sPicDst, (int)EnumLogLevel.DEBUG));
            if (pic.picType == 3)
            {
                try
                {
                    byte[] rgbBuf = new byte[pic.picWidth * pic.picHeight * 3];
                    Bitmap bm     = ConvertYUV2RGB(pic.picBufer, rgbBuf, pic.picWidth, pic.picHeight);
                    bm.Save(path + pic.picName);
                }
                catch (System.Exception ex)
                {
                    Global.LogServer.Add(new LogInfo("Error", "PictureWork->SavePic 图片存储失败:" + ex.Message, (int)EnumLogLevel.ERROR));
                }
            }
            else if (pic.picType == 0)
            {
                try
                {
                    MemoryStream ms  = new MemoryStream(pic.picBufer);
                    Image        img = Image.FromStream(ms);
                    img.Save(path + pic.picName, System.Drawing.Imaging.ImageFormat.Jpeg);
                    //img.Save("D:\\images\\"+DateTime.Now.ToString("yyyyMMddhhmmss")+".jpg");
                    ms.Dispose();
                    img.Dispose();
                }
                catch (System.Exception ex)
                {
                    Global.LogServer.Add(new LogInfo("Error", "PictureWork->SavePic 图片存储失败,图片路径" + path + pic.picName + ex.Message, (int)EnumLogLevel.ERROR));
                }
            }
        }