SRL Archive - Help

pasting bitmaps together


StevenV

2012-11-13 11:13:53

i have created a font of a website, problem with the font was the use of multiple colors. But i worked around it.
I made a textfinding script with that font. In this script simba is first searching for letter 1, then letter 2, ….
But this is rather a big script. So a was wondering if there would be a way in which i can make simba create a bitmap of al the letters and then go searching for the created bitmap of that word.
So what i need is a way of taking bitmapChr1 and paste behinde it bitmapChr2,…

thx

Olly

2012-11-13 11:15:58

Post your current code?

StevenV

2012-11-13 11:47:39

This is the procedure to find the text:

procedure FindText(text:string; Font:string; var Punten: Tpointarray);

var
i,j,x,y,w,h:integer;
CharNumber,CharBitmap: array of integer;
Words: Array of Tpointarray;
BmpSize: array of array of integer;
found: boolean;

begin
length(text);
setarraylength(CharNumber,length(text)+1);
setarraylength(CharBitmap,length(text)+1);
setarraylength(Words,length(text)+1);
setarraylength(BmpSize,length(text)+1);

for i := 1 to length(text) do
begin
for j:=0 to 127 do
begin
if (chr(j)=copy(text,i,1)) then
begin
CharBitmap:=loadbitmap('d:/Afbeeldingen/Test/'+Font+'/'+inttostr(j)+'.bmp');
settransparentcolor(charbitmap,16777215);
CharNumber:=j;
end;
end;
end;
getclientdimensions(w,h);

for i := 1 to getarraylength(BmpSize)-1 do
begin
setarraylength(BmpSize,2);
getbitmapsize(CharBitmap,BmpSize[0],BmpSize[1]);
if (i>1) then BmpSize[0]:=BmpSize[i-1][0]+BmpSize[0];
end;


for i := 1 to getarraylength(words)-1 do
begin
if (i=1) then
begin
FindBitmapsSpiralTolerance(charbitmap,x,y,Words,0,0,w-1,h-1,20);
end else
begin
for j:= 0 to getarraylength(Words[i-1])-1 do
begin
found := findbitmapIn(charbitmap,x,y,words[i-1][j].x+BmpSize[i-1][0],words[i-1][j].Y,words[i-1][j].x+BmpSize[0],words[i-1][j].y+BmpSize[1]);
if found then
begin
Setarraylength(words,getarraylength(Words)+1);
words[getarraylength(Words)-1]:=point(words[i-1][j].x,words[i-1][j].y);
end;
end;
end;
end;
a:= getarraylength(words);
b:= getarraylength(words[getarraylength(words)-1]);

for i:=0 to b-1 do
begin
setarraylength(Punten,b);
writeln(inttostr(words[a-1].x)+','+inttostr(words[a-1].y));
//movemouse(words[a-1].x,words[a-1].y);
Punten.x:= words[a-1].x;
Punten.y:= words[a-1].y;

wait(1000);
end;

end;


But is it possible to combine multiple bitmaps together to get 1 bitmap?

StevenV

2012-11-13 13:07:54

i have found a way to do so, the bitmap is completly the same as if what simba has to find, except for the white color, but before simba searches the bitmap, the white color is set to transparent.

even though it works if i am looking for 1 letter, it does not work for multple letter. it does not find the bitmap, even though it's really the same

Function BitmapWoord(Woord, Font:string):integer;
var
Canvas: TCanvas;
bitmap,bmpw,bmph,bitmapw,bitmaph,i,j:integer;
bmpcolors:t2dintegerarray;
a,b,x,y,w,h:integer;
CharNumber,CharBitmap: array of integer;
Words: Array of Tpointarray;
BmpSize: array of array of integer;
found: boolean;

begin
Bitmap:=Createbitmap(0,0)
setarraylength(CharBitmap,length(Woord)+1);
setarraylength(CharNumber,length(Woord)+1);

for i:= 1 to length(Woord) do
for j:=0 to 127 do
if (chr(j)=copy(Woord,i,1)) then
begin
CharBitmap:=loadbitmap('d:/Afbeeldingen/Test/'+Font+'/'+inttostr(j)+'.bmp');
//settransparentcolor(charbitmap,16777215);
CharNumber:=j;
getbitmapsize(CharBitmap,bmpw,bmph);
bmpcolors:=getbitmapareacolors(CharBitmap,0,0,bmpw-1,bmph-1);

getbitmapsize(bitmap,bitmapw,bitmaph);
Setbitmapsize(bitmap,bitmapw+bmpw,bitmaph+bmph);
for a:=0 to bmpw-1 do
for b:=0 to bmph-1 do
begin
fastsetpixel(Bitmap,Bitmapw+a,b,bmpcolors[a]);
end;
end;
Result:=Bitmap;

{DisplayDebugImgWindow(50,50);
cleardebugimg;
drawbitmapdebugimg(bmp);
drawbitmapdebugimg(bitmap);}
end;

riwu

2012-11-13 19:39:01

Try CreateBitmapMaskFromText then search the screen for the bitmap?