BCB copy code

zhaozj2021-02-08  225

Copy code

Tcanvas * dtcanvas = new tcanvas; dtcanvas-> handle = getdc (0);

Graphics :: Tbitmap * Bitmap = new graphics :: tbitmap; bitmap-> width = width; bitmap-> height = height;

int nColors = GetDeviceCaps (Canvas-> Handle, SIZEPALETTE); LOGPALETTE * logPal = (LOGPALETTE *) new Byte [sizeof (LOGPALETTE) (nColors-1) * sizeof (PALETTEENTRY)]; logPal-> palVersion = 0x300; logPal- > PALNUMENTRIES = (Word) Ncolors; getSystemPaletteentries (canvas-> handle, 0, ncolors, logpal-> palpalent); Bitmap-> Palette = CreatePalette (LogPal); delete [] logpal;

TRECT SRC = BoundSRect; TRECT DEST = Rect (0, 0, Width, Height); Bitmap-> Canvas-> CopyRect (DEST, DTCANVAS, SRC);

Bitmap-> SaveTofile ("Screen.BMP");

Delete Bitmap; Delete DTCANVAS;

转载请注明原文地址:https://www.9cbs.com/read-1546.html

New Post(0)