请教下在image控件中显示图片的问题

IDtoID IDtoID 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

'如何做才能通过图片的(长 与 宽)和(图片的像素)来显示图片呢?(就是打开时能像windows的图片和传真查看器一样,

'根据图片的(长 与 宽)和(图片的像素)来显示图片).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Form_Resize()'这样做在显示时只是作了适应大小的调整.....
Picture1.Top = 100
Picture1.Left = 100
Picture1.Width = Me.ScaleWidth - Picture1.Left - 100
Picture1.Height = Me.ScaleHeight - Picture1.Top - 100
End Sub

Private Sub Picture1_Resize()
Image1.Top = 0
Image1.Left = 0
Image1.Width = Picture1.Width
Image1.Height = Picture1.Height
Image1.Stretch = True
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'以下代码是来自下载的源码. 但看不懂是什么意思. (请教各位,如果要实现这样的效果该如何该呢?谢谢各位!)
Public Sub LoadPreview(FileName As String)
Dim ximg As cIMAGE
Dim PicRatio, xRatio As Single

Set ximg = New cIMAGE

With PicPreview
PicRatio = .Width / .Height
ximg.Load FileName
xRatio = ximg.ImageWidth / ximg.ImageHeight
If ximg.ImageHeight < ximg.ImageWidth Then
ximg.ReSize .Width * 15 / 16, 0, False
Else
ximg.ReSize 0, .Height * 15 / 16, False
End If
ImgPreview.Visible = False
ImgPreview.Left = (.ScaleWidth - ximg.ImageWidth) / 2
ImgPreview.Top = (.ScaleHeight - ximg.ImageHeight) / 2
ImgPreview.Width = ximg.ImageWidth
ImgPreview.Height = ximg.ImageHeight
ImgPreview.Picture = ximg.Picture
ImgPreview.Visible = True
.Tag = FileName
End With
Set ximg = Nothing

Exit Sub
Resume Next
End Sub

...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
IDtoID
控件 1,453 成员 41,351 内容