程序中调用的是bitblt API函数,该函数要求建立一个comptibleHDC,所以就这样做了
用bitblt API 有可能比delphi的作图快一点,但没有试验过

解决方案 »

  1.   

    destdc := Canvas.Handle;   //保存画布的句柄
      memdc := CreateCompatibleDC(destdc); 
      bm := CreateCompatibleBitmap(destdc, Width, Height); //创建内存位图
      sbm := SelectObject(memdc, bm);                      //开始在内存中的位图上画
      Canvas.Handle := memdc;     //这一句,主要是利用画布的pen,brush等定义好了的属性
      Draw;//画图形的函数 
      BitBlt(destdc,0,0,  Width,Height, memdc,0,0, SRCCOPY); //拷贝内存位图到画布
      SelectObject(memdc, sbm);
      DeleteObject(bm);
      Canvas.Handle := destdc;  //恢复
      DeleteDC(memdc);          //释放内部对象
      

  2.   

    你这个是典型的api的方法,可以尝试使用delphi的方式:
    var
       bmp:TBitmap;
    begin
       bmp:=TBitmpa.Create;
       bmp.width:=width;
       bmp.height:=height;
       try
         //Draw On The Bitmap
         //Draw the bitmap on the canvas
       finally
         bmp.free;
       end;
    end;