[atl/wtl]_[Intermediate]_[use Gdiplus to cut and zoom pictures]

Source: Internet
Author: User


Scene:

1. Zoom the picture, needless to say, is the need for thumbnails and painting on the interface of this kind.

2. Cut, needless to say, is to cut a portion of the picture used to draw the control background.

3. The wximage of Wxwidget is a direct method of bringing these functions.

gdiplus::bitmap* cutimage (gdiplus::image* source,int x,int y,int width,int height) { Gdiplus::rect zoomrect (0, 0, width,height); gdiplus::bitmap* Pimagescale_ = new Gdiplus::bitmap (zoomrect.width, zoomrect.height); GDIPLUS::RECTF RF (x,y,width,height); Gdiplus::texturebrush Brush (SOURCE,RF); Gdiplus::graphics Graphicsscale (Pimagescale_); Graphicsscale.fillrectangle (&brush, zoomRect); return Pimagescale_;} gdiplus::image* scaleimage (gdiplus::image* source,int width,int height) {gdiplus::rect zoomrect (0, 0, width,height); gdiplus::bitmap* Pimagescale = new Gdiplus::bitmap (zoomrect.width, zoomrect.height); Gdiplus::graphics Graphicsscale (Pimagescale); Gdiplus::texturebrush Brush (source); Graphicsscale.scaletransform ((Gdiplus::real) ((gdiplus::real) ZoomRect.Width/ (gdiplus::real) Source->getwidth ()), (Gdiplus::real) ((gdiplus::real) zoomrect.height/(Gdiplus::real) source- >getheight ())); Graphicsscale.fillrectangle (&brush, zoomrect); return pimagescale;} 


[atl/wtl]_[Intermediate]_[use Gdiplus to cut and zoom pictures]

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.