Click here to Skip to main content
15,905,877 members

Comments by ali 10 (Top 2 by date)

ali 10 28-Jun-13 16:20pm View    
i have created WritableBitmap in the dispatcher thread but it results in flickering of video i don't no why?? any idea about it
ali 10 26-Jun-13 4:41am View    
public MainWindow()
{
InitializeComponent();
client = new TcpClient();
client.Connect("127.0.0.1", 9000);
vedioframe = new Thread(Display_Frame);
vedioframe.Start();
WriteableBitmap vediofram = null;
}
public void Display_Frame()
{

ns = client.GetStream();


while (true)
{
byte[] vedio = new byte[1228800];
ns.Read(vedio, 0, vedio.Length);
try
{
if (vediofram == null)
{
vediofram = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);

}
else
{

vediofram.WritePixels(new Int32Rect(0, 0, 640, 480), vedio, 640 * 4, 0);
}
Update_Frame(vediofram);

}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

}
}
void Update_Frame(WriteableBitmap src)
{
Dispatcher.Invoke(new Action(() => { Vedio.Source = src; }));
}
this is the complete code i am receiving the video buffer and displaying it.The function display_frame() is a separate thread and this function is responsible for displaying video and Update_frame function is giving the error.Vedio is image control and vedio is a buffer as initialized in while loop