CopyRect Error

I intended to write a routine that loads a jpeg file
and shrinks it down to a thumbnail and appends it to
image2.canvas, which is a string of about 100 thumbnail
images. I had to jimmy it (see code) , to get it to work.
My problem is, while this works on some machines, it fails
on others. It fails at the CopyRect function with the
error message "the parameter is incorrect".
Thanks for the help.






jpeg := TJpegImage.Create;
if FileExists(fname) then
jpeg.LoadFromFile(fname);

bmp := TBitmap.Create;
bmp.Assign(jpeg);

BMRect:=Rect(0,0,jpeg.width,jpeg.height);
CRect:=Rect(Xpos,0,Xpos+THUMBWIDTH,THUMBHEIGHT);

image2.canvas.CopyRect(CRect,bmp.Canvas,BMRect);

bmp.Free;
jpeg.Free;



Comments

  • : I intended to write a routine that loads a jpeg file
    : and shrinks it down to a thumbnail and appends it to
    : image2.canvas, which is a string of about 100 thumbnail
    : images. I had to jimmy it (see code) , to get it to work.
    : My problem is, while this works on some machines, it fails
    : on others. It fails at the CopyRect function with the
    : error message "the parameter is incorrect".
    : Thanks for the help.
    :
    :
    :
    :
    :
    :
    : jpeg := TJpegImage.Create;
    : if FileExists(fname) then
    : jpeg.LoadFromFile(fname);
    :
    : bmp := TBitmap.Create;
    : bmp.Assign(jpeg);
    :
    : BMRect:=Rect(0,0,jpeg.width,jpeg.height);
    : CRect:=Rect(Xpos,0,Xpos+THUMBWIDTH,THUMBHEIGHT);
    :
    : image2.canvas.CopyRect(CRect,bmp.Canvas,BMRect);
    :
    : bmp.Free;
    : jpeg.Free;
    :
    :
    :
    :
    It could be due to differences in Delphi version. CHeck the help files for the correct definition of CopyRect() and update the code if necessary.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion