小编use*_*714的帖子

C++:Hbitmap/BITMAP到.bmp文件中

好吧,整个故事是,我试图在C++中使用Leptonica + Tesseract OCR截取屏幕截图,将其保存为*.bmp文件,然后将其加载回OCR.我不需要经常这样做,但由于我似乎无法将屏幕截图数据直接复制到Leptonica PIX结构中,我需要先将其保存到文件中......实际上,最好是解决这个问题.

这是我在网上找到的一些代码,试图帮助我.

屏幕上限:

HBITMAP ScreenCapture(){
  int width=100;
  int height=100;
  // get the device context of the screen
  HDC hScreenDC = CreateDC(L"DISPLAY", NULL, NULL, NULL);     
  // and a device context to put it in
  HDC hMemoryDC = CreateCompatibleDC(hScreenDC);

  int x = GetDeviceCaps(hScreenDC, HORZRES);
  int y = GetDeviceCaps(hScreenDC, VERTRES);

  // maybe worth checking these are positive values
  HBITMAP hBitmap = CreateCompatibleBitmap(hScreenDC, x, y);

  // get a new bitmap
  HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemoryDC, hBitmap);

  BitBlt(hMemoryDC, 0, 0, width, height, …
Run Code Online (Sandbox Code Playgroud)

c++ dib hbitmap leptonica

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

dib ×1

hbitmap ×1

leptonica ×1