Screencast video (1 Viewer)

Michael.K

Portal Member
February 14, 2012
25
0
Home Country
Ukraine Ukraine
So i have timer which ticks with 100ms interval. I need change image in ImageControl.
Now I have the following:
Code:
[SkinControlAttribute(20)]
protected GUIImage videoImage = null;
...
  public override void onStartVideo()
        {
            timer = new System.Timers.Timer(100);
            timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
            timer.Enabled = true; // Enable it
        }
void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            PixelFormat format = PixelFormat.Format32bppRgb;
            Bitmap b =  getFrame(format);
            if(tempbm==null) return;
                GUITextureManager.ReleaseTexture("[myfirstplugin:video]");
                int res = GUITextureManager.LoadFromMemory(b, "[myfirstplugin:video]",0x00000000, 100, 100);
                chack = !chack;
            }
            _videoImage.FileName = "";
            _videoImage.FileName = "[myfirstplugin:video]";
        }


But when image updating it very blink, about 3-5 times in second.
How can I solve this problem? Help me please.
 

Michael.K

Portal Member
February 14, 2012
25
0
Home Country
Ukraine Ukraine
May be possible to update the image without using GUITextureManageror use GUIImage.MemoryImage and then display it? Surely no one knows how to quickly update the image on GUIImage?
 

Michael.K

Portal Member
February 14, 2012
25
0
Home Country
Ukraine Ukraine
Now if save picture in hard disk and it displing but blinking, but if I load picture into GUITextureManager it does non happen(picture don't show). Who knows why this happens?
Code:
        public override void onStartVideo()
        {
            timer = new System.Timers.Timer(100);
            timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
            timer.Enabled = true; // Enable it
        }
 
        void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            timer.Stop();
            PixelFormat format = PixelFormat.Undefined;
            skypeBitmap = getFrame(format); // return Bitmap 640x480
            if (skypeBitmap == null)
            {
                timer.Start();
                return;
            }
            try
            {
                _oldTextureName = _textureName;
                bmskypeCrop = skypeBitmap.Clone(new Rectangle(0, 0, 640, 480), skypeBitmap.PixelFormat);
                // bmskypeCrop.Save(@"C:\" + sFrame.ToString() + ".png");
                _textureName = BuildMemoryImage(bmskypeCrop,"video" + sFrame);
                _videoImage.SetFileName(_textureName);
                // _videoImage.SetFileName(@"C:\" + sFrame.ToString() + ".png");
                // GUITextureManager.ReleaseTexture(@"C:\" + (sFrame - 1).ToString() + ".png");
                GUITextureManager.ReleaseTexture(_oldTextureName);
                    //if (File.Exists(@"C:\" + sFrame.ToString() + ".png"))
                    //    File.Delete(@"C:\" + sFrame.ToString() + ".png");
                _videoImage.Render(0f);
            }
            catch (Exception)
            {   
            }
            sFrame++;
            timer.Start();
        }
 
        private string BuildMemoryImage(Bitmap image,string identifier)
        {
            string str = string.Format("MyPlugin:[{0}]", identifier);
            try
            {
                GUITextureManager.LoadFromMemory(image, str, 0L,640,480);
            }
            catch(Exception)
            {
             
            }
            return str;
        }
 

Michael.K

Portal Member
February 14, 2012
25
0
Home Country
Ukraine Ukraine
I has understood what the problem is. I change my code on the following:
Code:
 public override void onStartVideo()
        {
            timer = new System.Timers.Timer(40);
            timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
            timer.Enabled = true; // Enable it
        }
 
        void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            timer.Stop();
            PixelFormat format = PixelFormat.Format32bppPArgb;
            skypeBitmap = getFrame(format); // return Bitmap 640x480
            if (skypeBitmap == null)
            {
                timer.Start();
                return;
            }
            try
            {
                _oldTextureName = _textureName;
                _textureName = BuildMemoryImage(skypeBitmap, "video" + sFrame);
                _videoImage.SetFileName(_textureName);
                GUITextureManager.ReleaseTexture(_oldTextureName);
                _videoImage.UpdateLayout();
            }
            catch (Exception)
            {
 
            }
            sFrame++;
            timer.Start();
        }
 
        private string BuildMemoryImage(Bitmap image, string identifier)
        {
            string str = string.Format("[myfirstplugin:{0}]", identifier);
            try
            {
                GUITextureManager.LoadFromMemory(image, str, 0L, 640, 480);
            }
            catch (Exception)
            {
 
            }
            return str;
        }
How i undestend problem was in string str = string.Format("[myfirstplugin:{0}]", identifier);
and _videoImage.UpdateLayout();
 

Users who are viewing this thread

Top Bottom