> 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?)

Since the code calling the function wants to use the bitmap, it MUST free it NOT your
function.

> 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); // Like a bitmap

1st Object Created

>   BMPtmp := TfastBMP.Create(wsize, hsize);

2nd Object Created

>   TempBMP := Tbitmap.Create;

3rd Object Created

>   try
>     TempBMP.Width := wsize;
>     TempBMP.Height := hsize;
>     BMPtmpB.SmoothResize(BMPtmp);
>     BMPtmp.Draw(TempBMP.canvas.handle, 0, 0);

Ummm... This is drawnig TempBMP onto BMTTmp but neither one
have anything on them since they were _just_ created. ?

>     result := TempBMP;

Result now POINTS to the 3rd Object

>   finally
>     begin
>       TempBMP.FreeImage; // If I'm free then result=nil

I'm not sure this is what you're wanting to do.
This releases the memory image of the 3rd Object created
which is also the object pointed to by Result

>       BMPtmp.Free;

Second Object freed

>       BMPtmpB.Free;

1st Object freed

>     end;
>   end;
> end;


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to