I have two bitmaps (integer). I want to draw bitmap_2 inside bitmap_1. I find function DrawBitmap(Bmp:integer ; Dest : Tcanvas ; x,y : integer);
But destination is in format Tcanvas. how to convert bmp(integer) to Tcanvas?
I have two bitmaps (integer). I want to draw bitmap_2 inside bitmap_1. I find function DrawBitmap(Bmp:integer ; Dest : Tcanvas ; x,y : integer);
But destination is in format Tcanvas. how to convert bmp(integer) to Tcanvas?
Simba Code:var
BMP, X, Y: Integer;
TBMP: TBitmap;
begin
BMP:= CreateBitmap(10, 10);
TBMP:= GetMufasaBitmap(BMP).ToTBitmap;
DrawBitmap(BMP, TBMP.Canvas, X, Y);
FreeBitmap(BMP);
TBMP.Free;
end.
I am Ggzz..
Hackintosher
And how to convert it back to bmp?
I tried:
butSimba Code:var
BMP, BMP2, X, Y: Integer;
TBMP: TBitmap;
MufasaBMP :TMufasaBitmap;
begin
BMP:= CreateBitmap(10, 10);
BMP2:= CreateBitmap(2, 2);
TBMP:= GetMufasaBitmap(BMP).ToTBitmap;
DrawBitmap(BMP2, TBMP.Canvas, X, Y);
MufasaBMP.LoadFromTBitmap(TBMP); // error here
BMP:=BitmapFromString(w,h,MufasaBMP.ToString);
DebugBitmap(BMP);
FreeBitmap(BMP);
TBMP.Free;
end.
Code:Error: Null Pointer Exception at line 32
Simba Code:program new;
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.Simba}
var
BMP, BMP2, X, Y, BMPH, BMPW: Integer;
TBMP: TBitmap;
MufasaBMP :TMufasaBitmap;
begin
BMPH:= 10;
BMPW:= 10; //Width and height respectfully.
BMP:= CreateBitmap(BMPH, BMPW); //You know this can be a string right? Such as BitmapFromString..
BMP2:= CreateBitmap(BMPH, BMPW); //Same as above..
TBMP:= GetMufasaBitmap(BMP).ToTBitmap;
DrawBitmap(BMP2, TBMP.Canvas, X, Y);
MufasaBMP:= GetMufasaBitmap(BMP); //Can probably swap this with a TMufasaBitmap.Create.. No difference I believe.
MufasaBMP.LoadFromTBitmap(TBMP);
BMP:= BitmapFromString(BMPW, BMPH, MufasaBMP.ToString);
DebugBitmap(BMP);
FreeBitmap(BMP);
FreeBitmap(BMP2);
TBMP.Free;
MufasaBMP.Free;
end.
I am Ggzz..
Hackintosher
Tyvm.
I made procedure to not muck with it anymore.
Simba Code:procedure DrawBmpInBmp(var Bmp ,DestBmp :integer; x , y :integer );
var
MufasaBMP :TMufasaBitmap;
Tbmp : Tbitmap;
begin
Tbmp:= GetMufasaBitmap(DestBmp).ToTBitmap;
DrawBitmap(bmp,Tbmp.canvas,x,y);
MufasaBMP:= GetMufasaBitmap(DestBmp);
MufasaBMP.LoadFromTBitmap(Tbmp);
DestBmp:=BitmapFromString(MufasaBMP.Width, MufasaBMP.Height ,MufasaBMP.ToString);
Tbmp.Free;
MufasaBMP.Free;
end;
Test:
Put cross on code.
Simba Code:program Test;
{$i srl/srl.simba}
{$I srl/srl/misc/debug.simba}
var // //
w, h: integer;
bmpx ,bmpx2: Integer;
// //
TPA ,bTPA: TPointArray;
bound :tbox;
procedure DrawBmpInBmp(var Bmp ,DestBmp :integer; x , y :integer );
var
MufasaBMP :TMufasaBitmap;
Tbmp : Tbitmap;
begin
Tbmp:= GetMufasaBitmap(DestBmp).ToTBitmap;
DrawBitmap(bmp,Tbmp.canvas,x,y);
MufasaBMP:= GetMufasaBitmap(DestBmp);
MufasaBMP.LoadFromTBitmap(Tbmp);
DestBmp:=BitmapFromString(MufasaBMP.Width, MufasaBMP.Height ,MufasaBMP.ToString);
Tbmp.Free;
MufasaBMP.Free;
end;
begin
GetClientDimensions(w,h);
bmpx:= CreateBitmap(w, h);
CopyClientToBitmap(bmpx, 0, 0, w -1, h -1);
FindColorstolerance(TPA,16711680,msx1,msy1,w-1,h-1,5);
bound :=GetTpaBounds(TPA);
bmpx2:= CreateBitmap(1,1);
bmpx2:= Bitmapfromclient(bound.x1,bound.y1,bound.x2,bound.y2);
bmpx2 := posterizebitmap(bmpx2,200);
//now we want to draw bmpx2 inside bmpx
DrawBmpInBmp(bmpx2, bmpx, bound.x1, bound.y1 );
DebugBitmap(BMPX);
FreeBitmap(BMPX);
FreeBitmap(BMPX2);
end.Works good despite of little memory leak.Code:The following bitmaps were not freed: [1, 2]Anyway
There are currently 1 users browsing this thread. (0 members and 1 guests)