Using double buffering technique to draw graphs

Source: Internet
Author: User

When the volume of data is large, the drawing may take several seconds or longer, and sometimes flicker, in order to solve these problems, you can use double buffering technology to draw graphs.

Double buffering creates an object in memory that is consistent with the screen drawing area, drawing the graphic to the object in memory, and then copying the graphic on the object to the screen at once, which can greatly speed up the drawing. The double buffering implementation process is as follows:

1, in memory to create a consistent canvas with the buffer

Bufferbmp=new Graphics::tbitmap ();

Bufferbmp->canvas->handle=createcompatibledc (Canvas->handle);

bufferbmp->width=width;

bufferbmp->height=height;

2, in the buffer paint

bufferbmp->canvas->brush->color=clbtnface;

Bufferbmp->canvas->fillrect (Rect (0,0,width,height));

Bufferbmp->canvas->moveto (...);

..............................

3. Copy the buffer bitmap to the current canvas

BitBlt (canvas->handle,0,0,width,height,bufferbmp->canvas->handle,0,0,srccopy);

4, free memory buffer

Delete bufferbmp;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.