Cimage converts an image to a specified pixel size

Source: Internet
Author: User

Cfiledialog fdlg (true, "jpg", "", ofn_hidereadonly | ofn_overwriteprompt, "JPG files (*. jpg) | *. jpg | ");

If (fdlg. domodal ()! = Idok) return;

Cimage imsrc, imdest;

Imsrc. Load (fdlg. getpathname ());

HDC = imsrc. getdc ();

CDC * PDC = CDC: fromhandle (HDC );

Cbitmap BMP;

BMP. createcompatiblebitmap (PDC, 152,200 );

CDC memdc;

Memdc. createcompatibledc (PDC );

Cbitmap * pold = memdc. SelectObject (& BMP );

: Setstretchbltmode (memdc. m_hdc, halftone );

: Setbrushorgex (memdc. m_hdc, 0, 0, null );

Imsrc. stretchblt (memdc. m_hdc, crect (152,200,)/* destrect */, crect (, imsrc. getwidth (), imsrc. getheight ()/* sourcerect */, srccopy );

// 152,200 is the width and height of the image you want (in pixels)

Hbitmap = (hbitmap) memdc. SelectObject (pold-> m_hobject );

Imdest. Attach (hbitmap); // load bitmap Resources

Cfiledialog fdlg1 (false, "BMP", "", ofn_hidereadonly | ofn_overwriteprompt, "BMP files (*. BMP) | *. BMP | ");

If (fdlg1.domodal ()! = Idok) return;

Imdest. Save (fdlg1.getpathname ());

Imsrc. releasedc ();

Imsrc. Destroy ();

Imdest. Destroy ();

Cimage converts an image to a specified pixel size

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.