VC++ uses GDI+ to realize the mutual conversion between HBITMAP and image files (with source code)

       Sometimes we need to load image files into HBITMAP in memory, and sometimes we need to save HBITMAP bitmaps in memory as image files. If only using GDI functions to deal with, it is more difficult to achieve, with the help of GDI + object we can easily achieve. In this article, let's talk about how to realize the mutual conversion between HBITMAP and image files.

1. Load the image file into the HBITMAP object

       First load the image file with the specified path into the CImage object , and then draw the image data in the CImage object into the HBITMAP. The CImage class is the MFC class that comes with Visual Studio, which is specially used to process image files. The CImage class is actually implemented using GDI+, so our current method is essentially implemented using GDI+

Guess you like

Origin blog.csdn.net/chenlycly/article/details/124081854