stata
2013-08-27 14:53:35
So i lifted this code from Dgby714's post in the Extensions thread on Appa
Works great, I'm able to color search in the appa window and everything, but the problem is after thousands of function calls everything starts to run very slowly. I only deal with bitmaps in this function call, and there doesn't seem to be any problem with unfreed bitmaps (Target isn't freed, but it is being constantly updated and I free it upon termination). So what's up with things slowing down? Do these appa functions have a memory leak or is something wrong with the code here?
btw, in the try block after appa_Copy, I inserted this line Bitmap.Canvas.Pixels[0, 0] := 0; as suggested by nielsie95 to activate the canvas.
Works great, I'm able to color search in the appa window and everything, but the problem is after thousands of function calls everything starts to run very slowly. I only deal with bitmaps in this function call, and there doesn't seem to be any problem with unfreed bitmaps (Target isn't freed, but it is being constantly updated and I free it upon termination). So what's up with things slowing down? Do these appa functions have a memory leak or is something wrong with the code here?
btw, in the try block after appa_Copy, I inserted this line Bitmap.Canvas.Pixels[0, 0] := 0; as suggested by nielsie95 to activate the canvas.
procedure appa_UpdateBitmap();
var
w1, h1, w2, h2: Integer;
Bitmap: TBitmap;
begin
if (not (appa_Showing())) then
Exit;
appa_GetSize(w1, h1);
if (Target = 0) then
Target := CreateBitmap(w1, h1);
GetBitmapSize(Target, w2, h2);
if ((w1 <> w2) or (h1 <> h2)) then
SetBitmapSize(Target, w1, h1);
Bitmap := GetMufasaBitmap(Target).ToTBitmap();
try
appa_CopyContentToBitmapDC(Bitmap.Canvas.Handle);
GetMufasaBitmap(Target).LoadFromTBitmap(Bitmap);
finally
Bitmap.Free;
end;
SetTargetBitmap(Target);
end;