C Win32: save .bmp image from HBITMAP

前端 未结 4 2092
谎友^
谎友^ 2021-02-20 07:13

I am working with a framegrabber and need to get the images from computer memory and save them on an image file. after trying for couple of days I end up with the following 2 fu

4条回答
  •  感动是毒
    2021-02-20 08:02

    I just find out I had a silly mistake in another part of my code I was using :

    // Convert Image to bitmap and display it
    DrawPicture( ghDCMain, pWinGBitmap, gpbImageData, lXSize, lYSize  );    
    if(counter!=1) {
      hBitmap2 = CreateCompatibleBitmap (hDCBits, lXSize, lYSize);
      SaveToFile(hBitmap2, "c:\\t.bmp");
      OutputDebugString("tested !!!!");
    }
    

    by deleting the hBitmap2 = CreateCompatibleBitmap (hDCBits, lXSize, lYSize); line, and changing the hBitmap2 to hBitmap the result of CreateDIBSection(), it saved the image beautifully. THANK YOU EVERYONE FOR YOUR HELP.

提交回复
热议问题