Board index » delphi » using bitblt function

using bitblt function

Hello
I am trying to do Double buffering by creating a memory DC and painting a
filled rectangle to it , and then using bitblt, copy it to the window's DC.
It doesn't worked for me, I think the problem was in painting to the memory
DC.
Has someone done it and can give me some sample code??

Thanks
Ran

 

Re:using bitblt function


On Sun, 23 Jul 2000 13:59:21 +0200, "Ran Kornfeld"

Quote
<rank...@internet-zahav.net> wrote:
>I am trying to do Double buffering by creating a memory DC

Not sure how you created a "memory DC", since you didn't say and you
didn't post sample code, but therein probably lies your problem.

Use an offscreen bitmap. The easiest way to do this is to use the
Delphi TBitmap class.
--
Rick Rogers (TeamB)
www.fenestra.com and www.componentfactory.com

Re:using bitblt function


Something like this?

procedure FillAndBlitRect(bmp: TBitmap; w,h: integer; pClr,bClr:
TColor;xpos,ypos: integer;ToDC: hDC);
begin
  bmp.Width := w;
  bmp.Height := h;
  bmp.Canvas.Pen.Color := pClr;
  bmp.Canvas.Brush.Color := bClr;
  bmp.Canvas.Rectangle(0,0,w,h);
  BitBlt(ToDC,xpos,ypos,w,h,bmp.Canvas.Handle,
         0,0,SRCCOPY);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  b : TBitmap;
begin
  b := TBitmap.Create;
  FillAndBlitRect(b,128,128,clBlack,clRed,60,60,Form1.Canvas.Handle);
  b.Free;
end;

--
Harm

http://www.users.uswest.net/~sharman1/

Cool Graphics, for free!

Quote
"Ran Kornfeld" <rank...@internet-zahav.net> wrote in message

news:397acd8b_2@dnews...
Quote
> Hello
> I am trying to do Double buffering by creating a memory DC and painting a
> filled rectangle to it , and then using bitblt, copy it to the window's
DC.
> It doesn't worked for me, I think the problem was in painting to the
memory
> DC.
> Has someone done it and can give me some sample code??

> Thanks
> Ran

Other Threads