DbImage1就是IMAGE,我起的一个名字而已var DrawRect:TRect;
ClearBitMap:TBitMap;
begin
DbImage1.Visible:=true;
ScrollBox1.HorzScrollBar.Range:=Round(0.8*DBimage1.Width); //按比率缩小
ScrollBox1.VertScrollBar.Range:=Round(0.8*DBimage1.Height);
DBimage1.Left:=0;
DBimage1.Top:=0;
DBimage1.Width:=ScrollBox1.HorzScrollBar.Range;
DBimage1.Height:=ScrollBox1.VertScrollBar.Range;
DBimage1.Picture.Bitmap.Width:=DBimage1.Width;
DBimage1.Picture.Bitmap.Height:=DBimage1.Height; DrawRect.Top:=0;
DrawRect.Left:=0;
DrawRect.Right:=DBImage1.Width;
DrawRect.Bottom:=DBImage1.Height;
ClearBitmap:=TBitmap.Create;
ClearBitmap.Width:=DBImage1.Width;
ClearBitmap.Height:=DBImage1.Height;
DBImage1.Picture.Bitmap.Canvas.Draw(0,0,ClearBitmap); //清空
ClearBitmap.Free;
DBImage1.Picture.Bitmap.Canvas.StretchDraw(DrawRect,image5.picture.Graphic);//重画
DBimage1.Refresh;
if (DBimage1.Width<ScrollBox1.Width) then DBimage1.Left:=(ScrollBox1.Width div 2 - dbimage1.Width div 2);//置中
if (DBimage1.Height<ScrollBox1.Height) then DBimage1.Top:=(ScrollBox1.Height div 2 - dbimage1.Height div 2);
ClearBitMap:TBitMap;
begin
DbImage1.Visible:=true;
ScrollBox1.HorzScrollBar.Range:=Round(0.8*DBimage1.Width); //按比率缩小
ScrollBox1.VertScrollBar.Range:=Round(0.8*DBimage1.Height);
DBimage1.Left:=0;
DBimage1.Top:=0;
DBimage1.Width:=ScrollBox1.HorzScrollBar.Range;
DBimage1.Height:=ScrollBox1.VertScrollBar.Range;
DBimage1.Picture.Bitmap.Width:=DBimage1.Width;
DBimage1.Picture.Bitmap.Height:=DBimage1.Height; DrawRect.Top:=0;
DrawRect.Left:=0;
DrawRect.Right:=DBImage1.Width;
DrawRect.Bottom:=DBImage1.Height;
ClearBitmap:=TBitmap.Create;
ClearBitmap.Width:=DBImage1.Width;
ClearBitmap.Height:=DBImage1.Height;
DBImage1.Picture.Bitmap.Canvas.Draw(0,0,ClearBitmap); //清空
ClearBitmap.Free;
DBImage1.Picture.Bitmap.Canvas.StretchDraw(DrawRect,image5.picture.Graphic);//重画
DBimage1.Refresh;
if (DBimage1.Width<ScrollBox1.Width) then DBimage1.Left:=(ScrollBox1.Width div 2 - dbimage1.Width div 2);//置中
if (DBimage1.Height<ScrollBox1.Height) then DBimage1.Top:=(ScrollBox1.Height div 2 - dbimage1.Height div 2);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货