Board index » delphi » BitBlt, hDc, Canvas, and all that jazz...

BitBlt, hDc, Canvas, and all that jazz...

I can not for the life of me get this method to work. All I want
is for this area to be tiled with pPic. I get no errors, but
nothing gets painted on the canvas.

procedure TTestClass.PaintSelf(const pPic:TPicture);
var
  r,c:integer;
  dc:hDc;
begin

  FSize:=32; //arbitrary figure, just for testing.

  dc:=self.canvas.Handle;
  for r:=0 to FRows -1 do
    for c:=0 to FCols -1 do
      BitBlt(dc,c*FSize, r*FSize, FSize,FSize,      
      pPic.Bitmap.Canvas.Handle,0,0,SRCCOPY);

end;

 

Re:BitBlt, hDc, Canvas, and all that jazz...


Try this instead:

canvas.brush.bitmap:=pPic.Graphic;
canvas.fillrect(myarearect);
canvas.brush.bitmap:=NIL;

a bit easier... and it tiles quite nice :)

Jon Lennart Berg

Chris Glavin <cavema...@hotmail.com> skrev i
meldingsnyheter:3cb61f1b$1_2@dnews...

Quote

> I can not for the life of me get this method to work. All I want
> is for this area to be tiled with pPic. I get no errors, but
> nothing gets painted on the canvas.

> procedure TTestClass.PaintSelf(const pPic:TPicture);
> var
>   r,c:integer;
>   dc:hDc;
> begin

>   FSize:=32; file://arbitrary figure, just for testing.

>   dc:=self.canvas.Handle;
>   for r:=0 to FRows -1 do
>     for c:=0 to FCols -1 do
>       BitBlt(dc,c*FSize, r*FSize, FSize,FSize,
>       pPic.Bitmap.Canvas.Handle,0,0,SRCCOPY);

> end;

Re:BitBlt, hDc, Canvas, and all that jazz...


Thanks Jon, I tried to implement your suggestion, but still
nothing gets painted.

procedure TTestClass.PaintSelf(const pPic:TPicture);
var
  r,c:integer;
begin
  FSize:=32; file://arbitrary figure, just for testing.
  for r:=0 to FRows -1 do
    for c:=0 to FCols -1 do begin
      canvas.brush.bitmap:=pPic.Bitmap;
      canvas.fillrect(Rect(FCellSize*c,FCellSize*r,
                           FCellSize*(c+1),FCellSize*(r+1)));
      canvas.brush.bitmap:=NIL;
    end;
end;

"Jon Lennart Berg" <jon...@c2i.net> wrote:

Quote

>Try this instead:

>canvas.brush.bitmap:=pPic.Graphic;
>canvas.fillrect(myarearect);
>canvas.brush.bitmap:=NIL;

>a bit easier... and it tiles quite nice :)

>Jon Lennart Berg

Re:BitBlt, hDc, Canvas, and all that jazz...


You don't need the FRows and FCols loops if you are using FillRect.
The FillRect rectangle should be the bounding rectangle of the ENTIRE area
you want to fill and not the size of a single tile.
FillRect will then use your Bitmap brush to fill that entire area.

So if you wanted to tile a bitmap onto a form,

MyForm.Canvas.FillRect(Myform.BoundsRect);

or

MyForm.Canvas.FillRect(MyForm.Canvas.ClipRect);

Regards

Stan.

Re:BitBlt, hDc, Canvas, and all that jazz...


That works quit nicely now, thanks!

Quote
"Stan" <s...@jetcam.net> wrote:
>You don't need the FRows and FCols loops if you are using FillRect.
>The FillRect rectangle should be the bounding rectangle of the ENTIRE area
>you want to fill and not the size of a single tile.
>FillRect will then use your Bitmap brush to fill that entire area.

>MyForm.Canvas.FillRect(MyForm.Canvas.ClipRect);

Re:BitBlt, hDc, Canvas, and all that jazz...


there is a size limit for Brush.Bitmap... you can't use more than a few
pixels...

Re:BitBlt, hDc, Canvas, and all that jazz...


Hi

in win9x only 2k and xp have no limit.

win9x has 8x8 pix  i think

cya

Quote
"Hamid HAJJI" <hamid.ha...@sympatico.ca> wrote in message

news:3cbdc402_2@dnews...
Quote
> there is a size limit for Brush.Bitmap... you can't use more than a few
> pixels...

Other Threads