| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 956 人关注过本帖
标题:[求助]按比例制作缩略图问题(api)
只看楼主 加入收藏
freeforever
Rank: 4
等 级:业余侠客
威 望:3
帖 子:368
专家分:201
注 册:2005-11-2
结帖率:66.67%
收藏
 问题点数:0 回复次数:5 
[求助]按比例制作缩略图问题(api)

Dim drv As String

Private Declare Function StretchBlt Lib "gdi32" ( _
ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal nSrcWidth As Long, _
ByVal nSrcHeight As Long, _
ByVal dwRop As Long) As Long

Private Sub Dir1_Change()
File1.path = Dir1.path
End Sub

Private Sub Dir1_Click()
With Dir1
.path = .List(.ListIndex)
End With
End Sub

Private Sub Dir1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
With Dir1
.ToolTipText = .List(.ListIndex)
End With
End Sub

Private Sub Drive1_Change()
On Error GoTo Err
Dir1.path = Drive1
Exit Sub
Err:
Drive1 = drv
End Sub

Private Sub File1_Click()
Set pic.Picture = Nothing
Set p.Picture = Nothing
Dim path As String
Dim x As Single
Dim blnW As Boolean
If pic.Width > pic.Height Then
x = pic.Width / pic.Height
blnW = True
Else
x = pic.Height / pic.Width
blnW = False
End If

path = Dir1.path
If Right(path, 1) <> "\" Then path = path & "\"
pic.Picture = LoadPicture(path & File1.FileName)
pic.Refresh: DoEvents
If blnW Then
x = p.Height / x: DoEvents
StretchBlt p.hdc, 0, 0, p.Width, Int(x), pic.hdc, 0, 0, pic.Width, pic.Height, vbSrcCopy
Else
x = p.Width / x: DoEvents
StretchBlt p.hdc, 0, 0, Int(x), p.Height, pic.hdc, 0, 0, pic.Width, pic.Height, vbSrcCopy
End If
p.Refresh
End Sub

Private Sub Form_Load()
drv = Drive1
End Sub

问题是出现的缩略图是油彩一样,怎样让它不失真?

搜索更多相关主题的帖子: Long ByVal api 缩略 Sub 
2006-08-03 01:23
清澂居士
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:1237
专家分:7
注 册:2006-12-19
收藏
得分:0 

其實用PAINPICTURE就可以叻 不必這么痲煩`


佛曰:\"前世的500次回眸才换来今生的一次擦肩而过\".我宁愿用来世的一次擦肩而过来换得今生的500次回眸.
2007-04-07 10:21
freeforever
Rank: 4
等 级:业余侠客
威 望:3
帖 子:368
专家分:201
注 册:2005-11-2
收藏
得分:0 
写个代码吧,我不会用PAINPICTURE,谢谢

其实我也很无聊!
2007-04-07 10:27
freeforever
Rank: 4
等 级:业余侠客
威 望:3
帖 子:368
专家分:201
注 册:2005-11-2
收藏
得分:0 
p2.PaintPicture p1.Picture, 0, 0, p2.ScaleWidth, p2.ScaleHeight

搞定了,其实自己试一下就知道了,呵呵,

其实我也很无聊!
2007-04-07 10:35
清澂居士
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:1237
专家分:7
注 册:2006-12-19
收藏
得分:0 
那個``對象瀏覽器裏麵有詳細的使用方法``

佛曰:\"前世的500次回眸才换来今生的一次擦肩而过\".我宁愿用来世的一次擦肩而过来换得今生的500次回眸.
2007-04-07 10:46
freeforever
Rank: 4
等 级:业余侠客
威 望:3
帖 子:368
专家分:201
注 册:2005-11-2
收藏
得分:0 
我都是直接拿来用,写不出就问,段懒人很省心的,呵呵

又改了下,按比例显示:
Dim xy As Single
xy = p1.ScaleHeight / p1.ScaleWidth
If xy > 1 Then '高大于宽
p2.Width = p2.Height * xy
Else
p2.Width = p2.Height / xy
End If
p2.PaintPicture p1.Picture, 0, 0, p2.ScaleWidth, p2.ScaleHeight

谢谢你呀,有你这样的好人在,我们有福了,呵呵

其实我也很无聊!
2007-04-07 10:57
快速回复:[求助]按比例制作缩略图问题(api)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014955 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved