Board index » delphi » Canvas Rectangle not working

Canvas Rectangle not working

Hello,

This is how I draw a border around an image:
Image1.canvas.Brush.Style:=bsClear;
Image1.canvas.rectangle(0,0,image1.width,image1.height);

which works fine until the image1.picture has a picture, then it
only draws the top and left lines of the border and fails to draw
the bottom and right side. Is this a known bug? Thanks.

 

Re:Canvas Rectangle not working


:) You have to take the picture width & height into account...

Example:

(After picture is inserted)

MyRect:=Rect(0,0,picture.graphic.width,picture.graphic.height);

Jon Lennart Berg

Chris Glavin <cavema...@hotmail.com> skrev i
meldingsnyheter:3cb59357_2@dnews...

Quote

> Hello,

> This is how I draw a border around an image:
> Image1.canvas.Brush.Style:=bsClear;
> Image1.canvas.rectangle(0,0,image1.width,image1.height);

> which works fine until the image1.picture has a picture, then it
> only draws the top and left lines of the border and fails to draw
> the bottom and right side. Is this a known bug? Thanks.

Re:Canvas Rectangle not working


That was it! Thank you!!!

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

Quote
>:) You have to take the picture width & height into account...

>Example:

>(After picture is inserted)

>MyRect:=Rect(0,0,picture.graphic.width,picture.graphic.height);

>Jon Lennart Berg

Re:Canvas Rectangle not working


Quote
> Image1.canvas.rectangle(0,0,image1.width,image1.height);

try
Image1.canvas.rectangle(0,0,image1.width-1,image1.height-1);

--
Andrew Rybenkov.

  ImageList utility
  "Imagizer: Click and Get It" available as
  beta-version at
  http://www.geocities.com/arybenkov/imagizer/

Re:Canvas Rectangle not working


"Chris Glavin" <cavema...@hotmail.com> a crit dans le message news:
3cb59357_2@dnews...

Quote

> Hello,

> This is how I draw a border around an image:
> Image1.canvas.Brush.Style:=bsClear;
> Image1.canvas.rectangle(0,0,image1.width,image1.height);

> which works fine until the image1.picture has a picture, then it
> only draws the top and left lines of the border and fails to draw
> the bottom and right side. Is this a known bug? Thanks.

Works for me in Delphi 4 if I draw the border either with a picture present
at designtime or if I load it at later.

Re:Canvas Rectangle not working


Of course, you would think that would work, but it doesn't.

Quote
"Andrew Rybenkov" <aryben...@hotmail.com> wrote:
>> Image1.canvas.rectangle(0,0,image1.width,image1.height);

>try
>Image1.canvas.rectangle(0,0,image1.width-1,image1.height-1);

Other Threads