一图片很大时,image正常不能全部显示,怎样按比例宿少图片再显示呢?

解决方案 »

  1.   

    var
        hh,ww,xx:real;
    begin
       hh:=236;  //image的高度
       ww:=188; //image的宽度
       if (hh < image1.Picture.Height) or (ww < image1.Picture.Width) then
       begin
        image1.Stretch :=true;
        if (hh / image1.Picture.Height) <  (ww / image1.Picture.Width) then
         xx:= image1.Picture.Height / hh
        else
         xx:=image1.Picture.Width / ww;     image1.Height :=image1.Picture.Height / xx;
         image1.width :=image1.Picture.width / xx;
        end
       else
        begin
         image1.Height :=hh;
         image1.Width :=ww;
         image1.Stretch :=false;
        end;
    end; 这段函数应该能满足你的要求
      

  2.   

    image1.Height :=image1.Picture.Height / xx;这里出错了
      

  3.   

    nihongjiang(jacky-ni) 的代码启示:
    如果那样行的话为什么不改成这样呢?:
    begin
       
        image1.Stretch :=true;
        image1.Picture.Width:=image1.width;
        image1.Picture.Height:=image1.heigth;end; 这段函数应该能满足你的要求
      

  4.   

    上面的函数应该可以实现这个功能我简单的解释一下函数思想吧 完了你可以自己改或写IF 图片高>image高 or 图片宽>image宽
    begin
       图片高=image高    图片宽=图片宽 X (image高/图片高)
    end;