如何让选中的图片自动根据Pic控件大小自动缩略~
如何让选中的图片自动根据Pic控件大小自动缩略~
楼主cg_i(半点闲)2002-05-14 15:00:00 在 VB / 控件 提问如何让选中的图片自动根据Pic控件大小自动缩略~ 问题点数:20、回复次数:8Top
1 楼gump2000(阿甘)回复于 2002-05-14 15:05:05 得分 5
PaintPicture方法
或者使用Image控件
Top
2 楼footballboy(郑创斌)回复于 2002-05-14 15:06:58 得分 5
在Form中添一个PictureBox,在Picture1里添一个image
Public Sub ScaleShowPic(Frm As Form, pic1 As PictureBox, Image1 As Image)
Dim scalew As Single, scaleh As Single, k As Single
Dim w As Long, h As Long
Dim oldw As Long, oldh As Long
Image1.Visible = False
oldw = Frm.ScaleX(Image1.Picture.Width, vbHimetric, vbTwips)
oldh = Frm.ScaleY(Image1.Picture.Height, vbHimetric, vbTwips)
Image1.Width = oldw
Image1.Height = oldh
scalew = Image1.Width / pic1.Width
scaleh = Image1.Height / pic1.Height
k = Image1.Width / Image1.Height
If scalew > 1 Or scaleh > 1 Then
If scalew <= scaleh Then
h = pic1.Height
w = k * h
Image1.Height = h
Image1.Width = w
Image1.Stretch = True
Else
w = pic1.Width
h = pic1.Width / k
Image1.Height = h
Image1.Width = w
Image1.Stretch = True
End If
Image1.Left = (pic1.Width - w) / 2
Image1.Top = (pic1.Height - h) / 2
Else
w = Image1.Width
h = Image1.Height
Image1.Stretch = True
Image1.Left = (pic1.Width - Image1.Width) / 2
Image1.Top = (pic1.Height - Image1.Height) / 2
End If
Image1.Visible = True
End Sub
Top
3 楼cg_i(半点闲)回复于 2002-05-14 15:48:37 得分 0
谢谢上面的两位前辈~~~我还没有试~~等份儿我就试。Top
4 楼footballboy(郑创斌)回复于 2002-05-14 15:56:08 得分 10
image的stretch设为trueTop
5 楼cg_i(半点闲)回复于 2002-05-14 16:09:35 得分 0
对不起~~~顺便问一句~~~上述得代码如何调用呢?Top
6 楼zhangxf2000(老七)回复于 2002-05-14 16:19:40 得分 0
同意楼上的,用image控件Top
7 楼footballboy(郑创斌)回复于 2002-05-14 16:28:08 得分 0
在一个窗体上放一个picturebox,picture中放一个image,image的stretch设为true,Top
8 楼footballboy(郑创斌)回复于 2002-05-14 16:31:47 得分 0
这样调用
ScaleShowPic Form1,PictureBox1,Image1
很久以前的代码,细节记不清了,你自己看后修改吧Top
-
相关文章
2秒记住本站域名
玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的readygo.com.cn
