Pascal To C Translation



我有一个程序,该程序拍摄了Pascal中的屏幕:

uses Graphics, 
     LCLIntf, 
     LCLType;
var  
     Screen:   TBitmap;
     ScreenDC: HDC;
begin
     Screen    := TBitmap.Create;
     ScreenDC  := GetDC(0);
     Screen.LoadFromDevice(ScreenDC);
     ReleaseDC(0, ScreenDC);
     Screen.SaveToFile("Screen.bmp");
end.

我的问题在于LoadFromDevice()SaveToFile()功能。可以使用什么函数(如果有)在C编程语言中实现这些功能。试图尽可能远离第三方图书馆。(Winapi)

看这个

HDC hDC = GetDC(g_hWnd); 
LPRECT rect = (LPRECT)malloc(sizeof(RECT)); 
GetWindowRect(g_hWnd,rect); 
int h = rect->right - rect->left;
int w = rect->bottom - rect->top; 
LPRECT rect = (LPRECT)malloc(sizeof(RECT)); 
GetWindowRect(g_hWnd,rect); 
HBITMAP hBmp = CreateCompatibleBitmap(hDC,w,h); 
PBITMAPINFO pbmi;
pbmi = CreateBitmapInfoStruct(g_hWnd,hBmp); 
CreateBMPFile(g_hWnd, TEXT("c:\TEMPO\TestG2.bmp"), pbmi, hBmp, hDC) ;
ReleaseDC(g_hWnd,hDC); 
DeleteObject(hBmp); 
DeleteObject(pbmi); 
if (rect != nullptr)
    free(rect); 

相关内容

  • 没有找到相关文章

最新更新