How can I take a screenshot and save it as JPEG on Windows?

前端 未结 11 1772
暖寄归人
暖寄归人 2020-12-02 15:11

I\'m trying to find a (somewhat) easy way to take a screenshot on window and save the resulting HBITMAP as a JPEG. The tricky part here is that since the code is in C I can\

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 15:29

    Try this at the begining of your code

    #include "windows.h"
    #include "gdiplus.h"
    using namespace Gdiplus;
    using namespace Gdiplus::DllExports;
    

    And GdipSaveImageToFile() may compile, in c++ i believe.

    In pure C, probably the best is to try to make single includes. Look for the functions declarations in "gdiplus.h" and add minimal includes for each of the functions that do not include namespaces, such as #include "Gdiplusflat.h" for the GdipSaveImageToFile()

提交回复
热议问题