In VC use CImage to convert picture format, display jpg and other format pictures

Source: Internet
Author: User

Copyright notice: When reprinted, please indicate the original source and author information of the article by hyperlink form and this statement
Http://chenet.blogbus.com/logs/28263560.html

Recently on Remote Desktop, you need to transfer pictures between the server and the client. As a direct screenshot of the BMP format, the picture is very large, so you need to compress it into a JPG format transmission. It took a long time to find a way to call an external library (JpgDll.dll) on the Internet. But it often goes wrong when used.

Later, people remind, only know that there is cimage this class.

Examples of CImage classes in MSDN2005:
Ms-help://ms. Vscc.v80/ms. Msdn.v80/ms. Visualstudio.v80.chs/dv_vcsample/html/4b6a0e30-5e37-4ef2-ae84-061540fa80e2.htm

use this class to first add #include <atlimage.h> to the stdafx.h.

save bmp as JPG:

CImage image;
Image. Load (TEXT ("e://images//1.bmp")); Load picture
Image. Save (TEXT ("e://images//1.jpg")); Save as Picture

show 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 ());//Show Picture

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.