精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● Delphi>>图形界面和窗体>>如何实现在image上的图平铺显示

主题:如何实现在image上的图平铺显示
发信人: limodou()
整理人: teleme(2000-12-06 17:36:03), 站内信件
【 在 perfic (bigcat之聪明的大貓) 的大作中提到: 】
: 我只找到拉伸

var
   bmp:TBitmap;
   i,j,cx,cy,d,x,y:integer;

首先生成一个TBitMap对象,
bmp:=TBitmap.create;
bmp.loadfromfile('your.bmp');
然后分别计算image1与bmp的大小,计算出横向与纵向要填充的图形个数
cx:=image1.width div bmp.width;
d:=image1.width mod bmp.width;
if d<>0 then 
   inc(cx);
cy:=image1.height div bmp.height;    
d:=image1.height mod bmp.height;
if d<>0 then
    inc(cy);
最后进行绘制
for i:=0 to cx-1 do
   for j:=0 to cy-1 do
   begin
      x:=i*bmp.width;
      y:=j*bmp.height;
      image1.canvas.copyrect(RECT(x, y,x+bmp.width,y+bmp.height),
         bmp.canvas,RECT(0,0.bmp.width,bmp.height));
   end;
试试看行吗?

--
Uploader2.0beta8 版主页上传软件,欢迎使用
http://smallroom.126.com http://smallroom.yeah.net

※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.106.250.103]

[关闭][返回]