Use cimage in VC to convert the image format and display jpg and other format images

Source: Internet
Author: User

Copyright statement: Reprinted with a hyperlinkArticleSource and author information and this statement
Http://chenet.blogbus.com/logs/28263560.html

Remote Desktop recentlyTo transmit images between the server and the client. Because the image is in the BMP format and the image size is large, you need to compress it into JPG format for transmission. I found a method to call the external library (jpgdll. dll) after finding it online for a long time. However, errors often occur during use.

I was notified later that the cimage class exists!

Example of the cimage class in msdn2005:
MS-help: // Ms. VSCC. v80/ms. msdn. v80/ms. visualstudio. v80.chs/dv_vcsample/html/4b6a0e30-5e37-4ef2-ae84-061540fa80e2.htm

To use this class, add # include <atlimage. h> to stdafx. h.

Save BMP as JPG:

Cimage image;
Image. Load (text ("E: // images // 1.bmp"));// Load the image
Image. Save (text ("E: // images // 1.jpg"));// Save as image

Display jpg:

Cimage image;
Crect zcrect;
Getclientrect (& zcrect );
Image. Load (text ("E: // images // 1.jpg"));
Image. Draw (getdc ()-> m_hdc, zcrect. Left, zcrect. Top, zcrect. Width (), zcrect. Height ());// Display the image

Other similarities.

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.