1 const
2 WW=600;
3 HH=800;
4 var
5 BmpBits:Pointer;
6 FDeskHWnd:Hwnd;
7 SourceDC,DestDC,originHandel:integer;
8 i:Integer;
9 ABitmap:HBitmap;
10 s:TBitmap;
11 BmpInfHead:TBitmapInfoHeader;
12 Info : TBitMapInfo;
13 bits:Pointer;
14 Apointer:Pointer;
15 begin
16 //Create DIB
17 Info.bmiHeader.biSize := sizeof(BITMAPINFOHEADER);
18 Info.bmiHeader.biWidth := WW; //width
19 Info.bmiHeader.biHeight := HH; //height
20 Info.bmiHeader.biPlanes := 1;
21 Info.bmiHeader.biBitCount := 16;
22 Info.bmiHeader.biClrUsed := 0;
23 Info.bmiHeader.biCompression := BI_RGB;
24 Info.bmiHeader.biClrImportant := 0;
25 ABitmap := CreateDIBSection(SourceDC, Info, DIB_RGB_COLORS, APointer, 0, 0);
26 SourceDC:= GetDC(0);
27 DestDC:=CreateCompatibleDC(SourceDC);
28 ABitmap:=CreateCompatibleBitmap(SourceDC,WW,HH);
29 originHandel:=selectObject(DestDC,Abitmap);
30 BitBlt(DestDC,0,0,WW,HH,SourceDC,0,0,SRCCOPY);
31 GetDIBits(DestDC,Abitmap,0,480,Apointer,info,DIB_RGB_COLORS);
32 s :=TBitmap.Create;
33 s.Handle :=ABitmap;
34 selectObject(DestDC,originHandel);
35
36 s.SaveToFile('d:\q2.bmp');
37 DeleteDC(DestDC);
38 ReleaseDC(0,SourceDC);
39 end;