最近使用paintbox来画图,但是效果不佳,按照网上的提示,DoubleBuffered := true,还有发送消息等均是无效。求大神们来一个双缓冲demo看看,看是不是有帮助。顺便说一下,paintbox是用来画图的,使用timer来刷,还有就是paintbox在panel上,该panel是用来接收一个实时流图像的。
   不知道有没有老鸟愿意教菜鸟的,可以请邮件至: [email protected]。菜鸟

解决方案 »

  1.   

    画什么图,实现什么功能啊
    自己用canvas画就是了,为什么效果不佳?
      

  2.   

    建立内存位图---->复制来源位图,或者画其他等工作---->显示到前台(PaintBox.Canvas与内存位图.Canvas 的交互)--->销毁内存位图
      

  3.   

    这和你画什么图 也有关,DoubleBuffered 并不能解决一切问题
      

  4.   

    Bitmap := TBitmap.Create;
    Bitmap.Width := ClientWidth;
    Bitmap.Height := ClientHeight;
    Bitmap.Brush.Color := clRed;
    Bitmap.Canvas.FillRect(ClientRect);
    Canvas.Draw(0, 0, Bitmap);
    Bitmap.Free;
      

  5.   

    双缓冲画图,DELPHI的源码里就有例子...如下:procedure TWinControl.WMPaint(var Message: TWMPaint);
    var
      DC, MemDC: HDC;
      MemBitmap, OldBitmap: HBITMAP;
      PS: TPaintStruct;
    begin
      if not FDoubleBuffered or (Message.DC <> 0) then
      begin
        if not (csCustomPaint in ControlState) and (ControlCount = 0) then
          inherited
        else
          PaintHandler(Message);
      end
      else
      begin
        DC := GetDC(0);
        MemBitmap := CreateCompatibleBitmap(DC, ClientRect.Right, ClientRect.Bottom);
        ReleaseDC(0, DC);
        MemDC := CreateCompatibleDC(0);
        OldBitmap := SelectObject(MemDC, MemBitmap);
        try
          DC := BeginPaint(Handle, PS);
          Perform(WM_ERASEBKGND, MemDC, MemDC);
          Message.DC := MemDC;
          WMPaint(Message);
          Message.DC := 0;
          BitBlt(DC, 0, 0, ClientRect.Right, ClientRect.Bottom, MemDC, 0, 0, SRCCOPY);
          EndPaint(Handle, PS);
        finally
          SelectObject(MemDC, OldBitmap);
          DeleteDC(MemDC);
          DeleteObject(MemBitmap);
        end;
      end;
    end;
      

  6.   

    双缓冲是利用TBitmap先画好,然后一次性Bitblt到控件上。
      

  7.   

    用Canvas.Pixels来画速度很慢,最好建立一张位图,利用ScanLine将图像数据写上去,然后再将位图显示到Canvas上。