图象合成示例:
(按显示十位示例,即记数不满十位的,已事先补0凑足十位。若想按实际记数显示,
只需修改算法既可)
//读字模图orig.bmp
orig:=Tbitmap.Create;
orig.LoadFromFile('orig.bmp');
//创建位图
newbmp:=Tbitmap.Create;
//确定显示尺寸
newbmp.Height:=orig.Height;
newbmp.Width:=orig.Width-2;
//计算单元尺寸
chunkx:=newbmp.Width div 10; //chunkx为合成图象的长度
chunky:=newbmp.Width; //chunky为合成图象的高度
//合成
for x:=0 to 9 do
begin
newx:=StrToInt(Copy(FStr,x+1,1)); //FStr为存放记数数字的字符型变量
newy:=0;
y:=0;
newbmp.Canvas.CopyRect(
rect(x*chunkx,y*chunky,(x+1)*chunkx,(y+1)*chunky),
orig.Canvas,
rect(newx*chunkx,newy*chunky,
(newx+1)*chunkx,(newy+1)*chunky));
end;