/// <summary>
        /// SaveImage saves the bytes to a file and returns the file name.  The cache is used to remember
        /// the temporary file names and to timeout (and delete) the file.
        /// </summary>
        /// <param name="ba"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        static internal string SaveImage(string path, byte[] ba, Cache c)
        {
            Stream io = null;
            string filename;
            string url;

            try
            {
                io = ImageHelper.GetIOStream(path, out filename, out url);

                io.Write(ba, 0, ba.Length);
                io.Close();
                io = null;
                ImageCallBack icb = new ImageCallBack();

                CacheItemRemovedCallback onRemove = new CacheItemRemovedCallback(icb.RemovedCallback);

                c.Insert(Path.GetFileNameWithoutExtension(filename),
                         filename, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero, CacheItemPriority.Normal, onRemove);
            }
            finally
            {
                if (io != null)
                {
                    io.Close();
                }
            }
            return(url);
        }
Esempio n. 2
0
        /****************************************************************************
        * @fn           RegisterImageCallBack
        * @brief        注册取流回调函数
        * @param        CallBackFunc          IN        回调函数
        * @param        pUser                 IN        用户参数
        * @return       成功:0;错误:-1
        ****************************************************************************/
        public int RegisterImageCallBack(ImageCallBack CallBackFunc, IntPtr pUser)
        {
            int nRet;

            nRet = m_pCSI.MV_CC_RegisterImageCallBack_NET(CallBackFunc, pUser);
            if (MyCamera.MV_OK != nRet)
            {
                return(CO_FAIL);
            }
            return(CO_OK);
        }
    public void InputAlbumSmallPicture(string LocalFileName, ImageCallBack callback, System.Action endcallback)
    {
        var file = new FileInfo(getAlbumSmallPicturesPath() + "/" + LocalFileName);

        if (!file.Exists)
        {
            endcallback();
            return;
        }

        StartCoroutine(Routine_LoadImage(file.FullName, callback, endcallback));
    }
    IEnumerator Routine_LoadImage(string FilePath, ImageCallBack callback, System.Action endcallback)
    {
        using (WWW www = new WWW("file:///" + FilePath))
        {
            //読み込み完了まで待機
            yield return(www);

            callback(www.texture);
        }
        //using (FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
        //{
        //    BinaryReader bin = new BinaryReader(fileStream);
        //    byte[] bytes = bin.ReadBytes((int)bin.BaseStream.Length);
        //    bin.Close();

        //    yield return null;

        //    int pos = 16; // 16バイトから開始

        //    int width = 0;
        //    for (int i = 0; i < 4; i++)
        //    {
        //        width = width * 256 + bytes[pos++];
        //    }

        //    int height = 0;
        //    for (int i = 0; i < 4; i++)
        //    {
        //        height = height * 256 + bytes[pos++];
        //    }

        //    Texture2D texture = new Texture2D(width, height);

        //    yield return null;
        //    callback(ref bytes, width, height);

        //    //texture.LoadImage(bytes);

        //    //yield return null;
        //    //Debug.Log("loadlimage");

        //    //callback(texture);
        //}
        yield return(null);

        endcallback();
        yield break;
    }
Esempio n. 5
0
 public static int Denoise(ImageCallBack image_callback, ProgressCallBack progress_CallBack, FinishedCallBack finished_callback)
 {
     if (File.Exists(input_image))
     {
         if (Directory.Exists(Path.GetDirectoryName(output_image)))
         {
             input_files     = new IntPtr[1];
             output_files    = new IntPtr[1];
             input_files[0]  = Marshal.StringToHGlobalAnsi(input_image);
             output_files[0] = Marshal.StringToHGlobalAnsi(output_image);
             return(DenoiseImp(1, input_files, output_files, blend, image_callback, progress_CallBack, finished_callback));
         }
         MessageBox.Show("The output directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     else
     {
         MessageBox.Show("The input image does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     return(-1);
 }
Esempio n. 6
0
        private void ChangeImage(string email, ContactAvailability status)
        {
            if (_mf.lvList.InvokeRequired)
            {
                ImageCallBack d = new ImageCallBack(ChangeImage);
                this._mf.Invoke(d, new object[] { email, status });
            }
            else
            {
                ListViewItem lvi = _mf.lvList.FindItemWithText(email);

                switch (status)
                {
                case ContactAvailability.Offline:
                case ContactAvailability.None:
                    lvi.ImageKey = "grey";
                    break;

                case ContactAvailability.Away:
                    lvi.ImageKey = "yellow";
                    break;

                case ContactAvailability.Busy:
                case ContactAvailability.BusyIdle:
                case ContactAvailability.DoNotDisturb:
                    lvi.ImageKey = "red";
                    break;

                case ContactAvailability.Free:
                case ContactAvailability.FreeIdle:
                    lvi.ImageKey = "green";
                    break;

                default:
                    lvi.ImageKey = "grey";
                    break;
                }
            }
        }
Esempio n. 7
0
 public static extern int DenoiseImp(int file_count, IntPtr[] input_files, IntPtr[] output_files, float blend, ImageCallBack image_callback, ProgressCallBack progress_CallBack, FinishedCallBack finished_callback);
Esempio n. 8
0
        /// <summary>
        /// SaveImage saves the bytes to a file and returns the file name.  The cache is used to remember
        /// the temporary file names and to timeout (and delete) the file.
        /// </summary>
        /// <param name="ba"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        static internal string SaveImage(string path, byte[] ba, Cache c)
        {
            Stream io = null;
            string filename;
            string url;
            try
            {
                io = ImageHelper.GetIOStream(path, out filename, out url);

                io.Write(ba, 0, ba.Length);
                io.Close();
                io = null;
                ImageCallBack icb = new ImageCallBack();

                CacheItemRemovedCallback onRemove = new CacheItemRemovedCallback(icb.RemovedCallback);
  
                c.Insert(Path.GetFileNameWithoutExtension(filename), 
                    filename, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero, CacheItemPriority.Normal, onRemove);
            
            }
            finally
            {
                if (io != null)
                    io.Close();
            }
            return url;
        }