lujin49

VC++ 截屏代码,并保存为想要的格式(BMP,JPG,PNG,GIF等格式)

void CCaptionScreenDlg::Screen(char* filename)
{
    HDC hdcSrc = ::GetDC(NULL);
    int nBitPerPixel = GetDeviceCaps(hdcSrc, BITSPIXEL);
    int nWidth = GetDeviceCaps(hdcSrc, HORZRES);
    int nHeight = GetDeviceCaps(hdcSrc, VERTRES);
    CImage image;
    image.Create(nWidth, nHeight, nBitPerPixel);
    BitBlt(image.GetDC(), 0, 0, nWidth, nHeight, hdcSrc, 0, 0, SRCCOPY);
    ::ReleaseDC(NULL, hdcSrc);
    image.ReleaseDC();
    image.Save((LPCTSTR)filename, Gdiplus::ImageFormatPNG);//ImageFormatJPEG
}

 

分类:

技术点:

相关文章:

  • 2021-08-05
  • 2022-01-01
  • 2021-10-21
  • 2021-10-06
  • 2021-06-02
  • 2021-11-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2021-08-30
  • 2022-02-24
  • 2021-11-19
  • 2021-11-27
相关资源
相似解决方案