Home > Back-end >  QT display video, turn to the MFC
QT display video, turn to the MFC

Time:09-23

Himself with the need of project, using the secondary development of video WRTC language, due to the above provided by QT interface, need to integrate the function on the MFC, so that the other functions are transplanted into the MFC,
Retransplantation video, QTdemo has the following code, means to obtain video shot, and then display interface,
Void VideoWidget: : paintEvent (QPaintEvent * e) {
{if (image_. The get ())
Static int frames=0;
Frames++;
if (! Timer2. IsValid ()) {
Timer2. Start ();
}
QImage QImage (image_. The get (), image_width_, image_height_, image_width_ * 4,
QImage: : Format_ARGB32);
QPainter painter (this);
Painter. Scale (float (this - & gt; Width ())/image_width_,
Float (this - & gt; Height ())/image_height_);
Painter. DrawImage (0, 0, qimage);

If (timer2. Elapsed () & gt; {
=1000)STD: : cout & lt; <"RPS:" & lt; <frames & lt; Frames=0;
Timer2. Restart ();
}
}
}

Void VideoWidget: : RenderFrame (STD: : unique_ptr & lt; ARGBBuffer> Video_frame) {
Static int frames=0;
Frames++;
if (! The timer. The isValid ()) {
The timer. The start ();
}
if (! Video_frame)
return;
If (image_width_!=video_frame - & gt; Resolution. The width | |
Image_height_!=video_frame - & gt; Resolution. Height) {
Image_width_=video_frame - & gt; Resolution. The width;
Image_height_=video_frame - & gt; Resolution. The height;
Image_height_ image_size_=image_width_ * * 4;
Image_. Reset (new uint8_t [image_size_]);
}
//STD: : copy (video_frame - & gt; Buffer, video_frame - & gt; Buffer + image_size_,
//image_. The get ());
Memcpy (image_. The get (), video_frame - & gt; Buffer, image_size_);

This - & gt; The update ();
If (timer elapsed () & gt; {
=1000)STD: : cout & lt; <"FPS:" & lt; <frames & lt; Frames=0;
The timer. Restart ();
}
}


I can get on the MFC shot, but anyway show not to come out,
HGLOBAL HGLOBAL=GlobalAlloc (GMEM_MOVEABLE image_size_);
Void * pData=https://bbs.csdn.net/topics/GlobalLock (hGlobal);
Memcpy (pData, video_frame - & gt; Buffer, image_size_);
GlobalUnlock (hGlobal);
Cost * pStream=NULL;
If (CreateStreamOnHGlobal (hGlobal, TRUE, & amp; PStream)==S_OK)
{
CImage * image=new CImage ();
Image - & gt; Create (image_width_ image_height_, image_width_ * 4);
//the Load cost Fail
HRESULT HRESULT=image - & gt; Load (pStream);

//CImage image;
////retrieves the hr=image. The Load (pStream);
//if (SUCCEEDED (image. The Load (TEXT (" 1111 PNG "))))
//{
//image. The Draw (GetDC () - & gt; M_hDC, 0,0,100,500);
//}
PStream - & gt; Release ();
}
GlobalFree (hGlobal);

How should I show this video images,
  • Related