图片 |
尚未結案
|
Azote
一般會員 ![]() ![]() 發表:6 回覆:4 積分:2 註冊:2004-04-14 發送簡訊給我 |
|
Vicen
高階會員 ![]() ![]() ![]() ![]() 發表:13 回覆:145 積分:151 註冊:2005-03-14 發送簡訊給我 |
花了一点时间,写了个范例,并将缩放模块写成函数,方便你的调用。
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, clipbrd, StdCtrls, ExtCtrls; type TFrmViewImage = class(TForm) ImgView: TImage; procedure FormResize(Sender: TObject); private procedure ImageAutoSize(ImgPicture: TImage; iWidth, iHeight: Integer); { Private declarations } public { Public declarations } end; var FrmViewImage: TFrmViewImage; implementation {$R *.dfm} procedure TFrmViewImage.FormResize(Sender: TObject); begin //调整窗口大小时自动缩放并居中显示 ImageAutoSize(ImgView, Self.ClientWidth, Self.ClientHeight); ImgView.Top := (Self.ClientHeight - ImgView.Height) Div 2; ImgView.Left := (Self.ClientWidth - ImgView.Width) Div 2; end; procedure TFrmViewImage.ImageAutoSize(ImgPicture: TImage; iWidth, iHeight : Integer); Var iOldWidth, iOldHeight, iSize : Integer; dW2H : Double; begin ImgPicture.AutoSize := False; ImgPicture.Stretch := True; //缩放比例系数 iSize := 1; //获得原始图片尺寸 iOldWidth := ImgPicture.Picture.Width; iOldHeight := ImgPicture.Picture.Height; //计算图片长高比例 dW2H := iOldWidth/iOldHeight; //按比例缩小 While (iOldWidth>iWidth) Or (iOldHeight>iHeight) do begin iOldWidth := iOldWidth-Round(iOldWidth * (iSize*dW2H/100)); iOldHeight := iOldHeight-Round(iOldHeight * (iSize*dW2H/100)); Inc(iSize); end; //显示比例图 ImgPicture.Width := iOldWidth; ImgPicture.Height := iOldHeight; end; end. |
malanlk
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
Azote
一般會員 ![]() ![]() 發表:6 回覆:4 積分:2 註冊:2004-04-14 發送簡訊給我 |
|
malanlk
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
pcplayer99
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:146 回覆:790 積分:632 註冊:2003-01-21 發送簡訊給我 |
引言: 如果您想將圖直接畫在窗口上 當然可以, 但是您想過嗎, 每當窗口被蓋住後又恢復, 移動後, 放大縮小 這個圖案都要重畫, 所以一定要有地方存一份原始圖案, 不然每次都要去讀檔案 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |