How to quickly clear a large TCanvas (Views: 27)
Problem/Question/Abstract: How to quickly clear a large TCanvas Answer: You can use the PatBlt API call for this purpose. The function takes six parameters: HDC: hdc - The handle of the canvas to be cleared nXleft: integer - X coordinate of the upper left corner of canvas to be cleared nYleft: integer - Y coordinate of the upper left corner of canvas to be cleared nWidth: integer - The width of the canvas to be cleared nHeight: integer - The height of the canvas to be cleared dwRop: dWord - Raster operation code (WHITENESS in our case, for clearing the canvas) To be used like this: { ... } PatBlt(Image1.Canvas.Handle, 0, 0, Image1.Width, Image1.Height, WHITENESS); Image1.Refresh; { ... } Instead of WHITENESS you could also use: PATCOPY - Copies the specified pattern into the destination bitmap PATINVERT - Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean OR operator DSTINVERT - Inverts the destination rectangle BLACKNESS - Fills the destination rectangle using the color associated with index 0 in the physical palette (This color is black for the default physical palette) WHITENESS - Fills the destination rectangle using the color associated with index 1 in the physical palette (This color is white for the default physical palette) |