Log in

View Full Version : pasting bitmaps together



StevenV
11-13-2012, 04:13 PM
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
11-13-2012, 04:15 PM
Post your current code?

StevenV
11-13-2012, 04:47 PM
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[i]:=loadbitmap('d:/Afbeeldingen/Test/'+Font+'/'+inttostr(j)+'.bmp');
settransparentcolor(charbitmap[i],16777215);
CharNumber[i]:=j;
end;
end;
end;
getclientdimensions(w,h);

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


for i := 1 to getarraylength(words)-1 do
begin
if (i=1) then
begin
FindBitmapsSpiralTolerance(charbitmap[i],x,y,Words[i],0,0,w-1,h-1,20);
end else
begin
for j:= 0 to getarraylength(Words[i-1])-1 do
begin
found := findbitmapIn(charbitmap[i],x,y,words[i-1][j].x+BmpSize[i-1][0],words[i-1][j].Y,words[i-1][j].x+BmpSize[i][0],words[i-1][j].y+BmpSize[i][1]);
if found then
begin
Setarraylength(words[i],getarraylength(Words[i])+1);
words[i][getarraylength(Words[i])-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][i].x)+','+inttostr(words[a-1][i].y));
//movemouse(words[a-1][i].x,words[a-1][i].y);
Punten[i].x:= words[a-1][i].x;
Punten[i].y:= words[a-1][i].y;

wait(1000);
end;

end;

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

StevenV
11-13-2012, 06:07 PM
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[i]:=loadbitmap('d:/Afbeeldingen/Test/'+Font+'/'+inttostr(j)+'.bmp');
//settransparentcolor(charbitmap[i],16777215);
CharNumber[i]:=j;
getbitmapsize(CharBitmap[i],bmpw,bmph);
bmpcolors:=getbitmapareacolors(CharBitmap[i],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][b]);
end;
end;
Result:=Bitmap;

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

riwu
11-14-2012, 12:39 AM
Try CreateBitmapMaskFromText then search the screen for the bitmap?