TMufasa To TBitmap Directly
Is there a way to go from TMufasaBitmap to TBitmap directly without it creating a middleman copy? OR is there a way to go from TBitmap to Integer Handle bmp's Directly?
Example of what I do not want:
Simba Code:
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.Simba}
Procedure MiddleMan;
var
TM: TMufasaBitmap;
TB: TBitmap;
begin
TM := TMufasaBitmap.create;
TB := TBitmap.Create;
TB.Width := 200;
TB.Height := 200;
TB.Canvas.Pen.COLOR := 16777215;
TB.Canvas.Rectangle(0, 0, 100, 100);
TM.LoadFromTBitmap(TB);
TB.Free;
DebugBitmap(TM.Index);
TM.Free;
end;
Procedure Wanted;
var
TM: TMufasaBitmap;
begin
TM := TMufasaBitmap.create;
SetBitmapSize(TM.Index, 200, 200);
TM.ToTBitmap.Canvas.Pen.Color := 16777215;
TM.ToTBitmap.Canvas.Rectangle(0, 0, 100, 100);
DebugBitmap(TM.Index);
TM.Free;
end;
Procedure SimilarWanted;
var
BMP: Integer;
begin
BMP := CreateBitmap(200, 200);
GetMufasaBitmap(BMP).Rectangle(IntToBox(0, 0, 100, 100), 255);
DebugBitmap(BMP);
FreeBitmap(BMP);
end;
begin
Wanted; //Draws Nothing..
Wait(1500);
MiddleMan; //Draws A White Box..
Wait(1500);
SimilarWanted; //Draws A Red Box..
end.
See the difference? The first uses a middleman TBitmap and it works find and dandy. The second does not use a middle man but guess what? The second is a memory leak since the TBitmap created is from raw data but is not freed. We all saw what happens before when you assign to a result directly.
The third uses an integer handle which is just a property of the mufasa class. All bitmaps are essentially TMufasaBitmap.Index. They're swapable from Int To TMufasa To Int. This is not the case with TBitmap to anything To TBitmap. Anyone know how to do it?
Why? Because if I draw on the TBitmap after doing ToTBitmap, the TMufasa will not have that drawing on it's canvas unless I load it from a separate TBitmap.
I also want to know how to index a TBitmap. It's not the same as TBitmap.Handle. What use is the handle if I can't use it?
Mufasa's class has TMufasaBitmap.index which is the same as doing BMP: Integer; That's perfect. But TBitmap has no such thing :S