Aargh, I should have waited!  :)

You don't need to free TempBMP.  You want the function to return a newly
created bitmap, and TempBMP (the variable) is just another pointer to
that which will be destroyed when SizeFunc ends.  Let the calling
routine free the bitmap when its finished with it.

MyBitmap := SizeFunc(MyOrigBitmap);
// Do stuff with MyBitmap
MyBitmap.Free;

Cheers,

Carl Reynolds                      Ph: +64-9-4154790
CJN Technologies Ltd.             Fax: +64-9-4154791
[EMAIL PROTECTED]                DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/

> -----Original Message-----
> From: Alistair George [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, July 28, 1999 8:39 AM
> To:   Multiple recipients of list delphi
> Subject:      RE: [DUG]: Any comments
> 
> Thanks guys, but my example code was whipped up on the spot. Not a
> good
> example.
> In the example below, if I free TempBMP the value doesnt get returned.
> So
> how do I kick ass with TempBMP when I have finished with it? (maybe
> @TempBMP
> then free?)
> 
> 
> function Tcamform.SizeFunc(BMap: Tbitmap): Tbitmap;
> var
>   BMPtmp, BMPtmpB: TFastBMP;
>   TempBMP: Tbitmap;
>   wsize, hsize: word;
>   fval1, fval2: single;
> begin
> //a whole lotta code goes here
>   BMPtmpB := TfastBMP.CreateFromhBmp(BMap.handle); //LikeABitmap
>   BMPtmp := TfastBMP.Create(wsize, hsize);
>   TempBMP := Tbitmap.Create;
>   try
>     TempBMP.Width := wsize;
>     TempBMP.Height := hsize;
>     BMPtmpB.SmoothResize(BMPtmp);
>     BMPtmp.Draw(TempBMP.canvas.handle, 0, 0);
>     result := TempBMP;
>   finally
>     begin
>       TempBMP.FreeImage; //If I'm free then result=nil
>       BMPtmp.Free;
>       BMPtmpB.Free;
>     end;
>   end;
> end;
> 
> ----------------------------------------------------------------------
> -----
>     New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz

application/ms-tnef

Reply via email to