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

首頁 > 開發 > 綜合 > 正文

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

2024-07-21 02:24:29
字體:
來源:轉載
供稿:網友
代碼如下:

'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




發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 屏南县| 莲花县| 江阴市| 重庆市| 万安县| 荣成市| 淄博市| 绥中县| 靖边县| 合山市| 大竹县| 定州市| 凌海市| 工布江达县| 奎屯市| 常山县| 秭归县| 巴楚县| 双牌县| 浠水县| 藁城市| 永和县| 深水埗区| 察雅县| 鹤峰县| 桃园县| 灵丘县| 友谊县| 大田县| 民县| 石城县| 许昌市| 上蔡县| 南汇区| 承德市| 丰城市| 青岛市| 蓬莱市| 绥中县| 油尖旺区| 平江县|