Read and display JPEG stream video streams

Source: Internet
Author: User

Char URL [1000] = "http: // 192.168.131.129: 8080 /? Action = snapshot ";
 

// Cout <"target Address URL:" <URL <Endl;

Unsigned char * buffer = new byte [100000];

DWORD bytes_read;
Hinternet Internet = internetopen ("HTTP downloader", internet_open_type_preconfig,
Null, null, null );

If (! Internet)
Return;

Hinternet file_handle = internetopenurl (Internet, URL, null, 0, internet_flag_reload, 0 );
If (! File_handle)

Return;
Void * pimagememory = globallock (buffer );
Bool B = internetreadfile (file_handle, pimagememory, 100000, & bytes_read );
Globalunlock (pimagememory); // unlock memory
If (! B)
Return;

CDC * PDC = getdlgitem (idc_showimg)-> getdc ();

HDC = PDC-> getsafehdc ();
Crect rect;
Getdlgitem (idc_showimg)-> getclientrect (& rect );

Istream * pistream; // create an istream interface pointer to save the image stream.
Ipicture * pipicture; // create an ipicture interface pointer to indicate the image object.
Createstreamonhglobal (pimagememory, false, & pistream); // use the istream interface pointer in the global memory.
Oleloadpicture (pistream, 0, false, iid_ipicture, (lpvoid *) & (pipicture); // obtain ipicture with oleloadpicture

Long hmwidth;
Long hmheight;

Pipicture-> get_width (& hmwidth); // obtain the image width and height using the interface
Pipicture-> get_height (& hmheight );
Pipicture-> render (HDC, 0,0, 640,480, 0, hmheight, hmwidth,-hmheight, null );

// Handle hfile = createfile (_ T (file_handle), generic_read, 0, null, open_existing, 0, null );
// Buffer [bytes_read] = 0;
// Delete [] buffer;

Globalfree (pimagememory); // release global memory
Pistream-> release (); // release pistream
Pipicture-> release (); // release pipicture

Internetclosehandle (Internet );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.