国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

將一個圖片按比例縮放顯示在一個Frame中。

2024-07-21 02:16:23
字體:
來源:轉載
供稿:網友
,歡迎訪問網頁設計愛好者web開發。代碼如下:

'form1.frm
version 5.00
object = "{f9043c88-f6f2-101a-a3c9-08002b2f49fb}#1.2#0"; "comdlg32.ocx"
begin vb.form form1
caption = "form1"
clientheight = 5010
clientleft = 60
clienttop = 345
clientwidth = 7800
linktopic = "form1"
scaleheight = 334
scalemode = 3 'pixel
scalewidth = 520
startupposition = 3 '窗口缺省
begin mscomdlg.commondialog commondialog1
left = 4635
top = 3120
_extentx = 847
_extenty = 847
_version = 393216
end
begin vb.frame frame1
caption = "frame1"
height = 3000
left = 4500
tabindex = 2
top = 30
width = 3180
begin vb.picturebox picture2
appearance = 0 'flat
forecolor = &h80000008&
height = 2625
left = 120
scaleheight = 173
scalemode = 3 'pixel
scalewidth = 194
tabindex = 3
top = 255
width = 2940
begin vb.image image1
height = 1575
left = 465
top = 390
width = 1965
end
end
end
begin vb.commandbutton command1
caption = "&load picture"
height = 330
left = 5400
tabindex = 0
top = 3150
width = 1425
end
begin vb.picturebox picture1
appearance = 0 'flat
autosize = -1 'true
borderstyle = 0 'none
forecolor = &h80000008&
height = 4425
left = 60
scaleheight = 4425
scalewidth = 4380
tabindex = 1
top = 105
width = 4380
end
end
attribute vb_name = "form1"
attribute vb_globalnamespace = false
attribute vb_creatable = false
attribute vb_predeclaredid = true
attribute vb_exposed = false
option explicit

dim returnheight as long, returnwidth as long

private sub command1_click()
dim bigwidth as long, bigheight as long
dim stretchwidth as long, stretchheight as long
commondialog1.filter = "jpeg文件|*.jpg|gif文件|*.gif|所有文件|*.*"
commondialog1.showopen
if commondialog1.filename <> "" then
picture1.picture = loadpicture(commondialog1.filename)

bigwidth = picture1.width
bigheight = picture1.height
stretchwidth = picture2.scalewidth
stretchheight = picture2.scaleheight

stretchimage bigwidth, bigheight, stretchwidth, stretchheight, true

image1.stretch = true
image1.width = returnwidth
image1.height = returnheight

image1.left = (picture2.scalewidth - image1.width) / 2
image1.top = (picture2.scaleheight - image1.height) / 2
image1.picture = loadpicture(commondialog1.filename)
end if
end sub

private sub stretchimage(originalwidth as long, originalheight as long, stretchwidth as long, stretchheight as long, optional flag as boolean = false)
if (originalwidth >= stretchwidth or originalheight > stretchheight) or flag = true then '需要縮放
if originalwidth / originalheight >= stretchwidth / stretchheight then
returnwidth = stretchwidth
returnheight = stretchwidth / originalwidth * originalheight
else
returnheight = stretchheight
returnwidth = stretchheight / originalheight * originalwidth
end if
else
returnheight = originalheight
returnwidth = originalwidth
end if
end sub

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 开原市| 新沂市| 芦山县| 洞口县| 伊春市| 界首市| 汤原县| 高唐县| 舞钢市| 大理市| 水富县| 冷水江市| 罗甸县| 江津市| 仁怀市| 天水市| 通道| 外汇| 福建省| 凌海市| 浮梁县| 阿巴嘎旗| 新龙县| 华蓥市| 隆安县| 太仓市| 方山县| 顺平县| 孝义市| 铜梁县| 远安县| 铜川市| 安西县| 东乡| 东山县| 德兴市| 沂水县| 周至县| 美姑县| 柳林县| 报价|