This article from http://blog.csdn.net/hellogv/
First, this article is suitable for JPEG and GIF images that are transmitted over the network, because these images are transmitted in the form of byte arrays. Give the function directly, not to mention nonsense!// ----------- Put the following two sentences in the header file definition # include "gdiplus. H "using namespace gdiplus; // ----------- the following code modifies the variable to its own variable and uses void readfrombuffer (char * video_data, int size) {gdiplusstartupinput m_gdiplusinput; ulong_ptr m_gdipluw.en; gdiplusstartup (& m_gdiplustoken, & m_gdiplusinput, null); // initialize GDI + ipicture * PPIC; istream * PSTM; // allocate global storage space hglobal = globalalloc (gmem_moveable, size ); lpvoid pvdata = NULL; // lock the allocation Memory block pvdata = globallock (hglobal); // copy the data packet video_data to pvdatamemcpy (pvdata, video_data, size); globalunlock (hglobal); createstreamonhglobal (hglobal, true, & PSTM ); ularge_integer limit EK; large_integer dlibmove = {0}; PSTM-> seek (dlibmove, stream_seek_set, & pseek); sleep (15 ); // mount the image file if (failed (oleloadpicture (PSTM, size, true, iid_ipicture, (lpvoid *) & PPIC) {// attached: if the image contained in the video_data array is incorrect, oleloadpicture is prone to read/write memory errors. PPIC-> r Elasticsearch (); PSTM-> release (); return;} image IMG (PSTM, 0); graphics mgraphics (getdc (hwnd); mgraphics. drawimage (& IMG, 0, 0, video_width, video_height); IMG. ~ Image (); // an error occurs in mgraphics .~ Graphics (); PPIC-> release (); PSTM-> release (); gdiplusshutdown (m_gdiplustoken); // destroy GDI +}