如在ImageList1(ImageList1.Add(BmpPht,BmpPht))中添加了一张图片大于Imagelist1设置的宽度和高度,使图片只显示了一部分,如何让添加的图片自动缩小(适应)成与ImageList1宽度与高度一致,并正常显示所有部分出来

解决方案 »

  1.   

    怎么设Stretch := True;?TImageList和TBitmap都不含有Stretch属性!
      

  2.   

    var
      vBitmap: TBitmap;
      vTemp: TBitmap;
    begin
      vBitmap := TBitmap.Create;
      vTemp := TBitmap.Create;
      try
        vBitmap.LoadFromFile('c:\temp\temp.bmp');
        vTemp.Width := ImageList1.Width;
        vTemp.Height := ImageList1.Height;
        vTemp.Canvas.StretchDraw(vTemp.Canvas.ClipRect, vBitmap);
        ImageList1.Add(vTemp, vTemp);
      finally
        vTemp.Free;
        vBitmap.Free;
      end;
    end;