图片翻转以后为什么保存不了?

windsandy 2004-09-12 06:21:58
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long

Private Sub Command1_Click()
Picture2.Refresh
RltPic True
End Sub

Sub RltPic(TrunLeft As Boolean) '
Dim X As Long
Dim Y As Long
Dim Hdc1 As Long
Dim Hdc2 As Long
With Picture1
Picture2.Width = .Height '交换长宽
Picture2.Height = .Width '交换长宽
Hdc1 = .hDC '获得句炳
Hdc2 = Picture2.hDC '获得句炳
If TrunLeft Then
For X = 0 To .ScaleWidth - 1
For Y = 0 To .ScaleHeight - 1
SetPixelV Hdc2, Y, .ScaleWidth - X, GetPixel(Hdc1, X, Y) '转置图像
Next
Next
Else
For X = 0 To .ScaleWidth - 1
For Y = 0 To .ScaleHeight - 1
SetPixelV Hdc2, .ScaleHeight - Y, X, GetPixel(Hdc1, X, Y) '转置图像
Next
Next
End If
End With
End Sub
图片翻转以后
用 SavePicture Picture2.Picture, "d:\ddd.gif" 保存不了图片
请问怎么解决?
...全文
598 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
147896325 2004-09-14
  • 打赏
  • 举报
回复
学习
熊孩子开学喽 2004-09-13
  • 打赏
  • 举报
回复
将PICTUREBOX的AutoRedraw 属性设为TRUE,画好以后,使用REFRESH方法来将图像显示出来,最后使用SAVEPICTURE函数来保存图像(只能保存为BMP格式)
vbfunner 2004-09-12
  • 打赏
  • 举报
回复
你可以用STRETCHBLT啊!
zyh_jason 2004-09-12
  • 打赏
  • 举报
回复
picture.image保存的才是当前图像
laviewpbt 2004-09-12
  • 打赏
  • 举报
回复
同意大斑竹的意见。
rainstormmaster 2004-09-12
  • 打赏
  • 举报
回复
同意楼上,另外你的代码的效率太低了,可以考虑用imgedit控件实现,几句代码就够了(如果是win2000以上的话,还可以用api函数PlgBlt实现)

另外,如果想保存为gif图片的话,用savepicture是不行的,尽管你保存文件的扩展名为gif,但是它本质上还是bmp图片

基于以上考虑,我建议你用imgedit控件(它可以保存gif、jpg、tif、bmp等格式的文件)
laviewpbt 2004-09-12
  • 打赏
  • 举报
回复
为什么用GetPixel、SetPixelV 这两个PAI函数啊,速度太慢了
http://community.csdn.net/Expert/topic/3262/3262150.xml?temp=5.283755E-02
http://community.csdn.net/Expert/topic/3312/3312140.xml?temp=.3141596
http://community.csdn.net/Expert/topic/3339/3339102.xml?temp=1.346987E-02
http://community.csdn.net/Expert/topic/3319/3319905.xml?temp=.4843866
laviewpbt 2004-09-12
  • 打赏
  • 举报
回复
picture2.picture=picture2.iamge
SavePicture Picture2.picture, "d:\ddd.gif
laviewpbt 2004-09-12
  • 打赏
  • 举报
回复
自己绘制的picture,保存前需要加PicDay.Picture = picDay.Image
tztz520 2004-09-12
  • 打赏
  • 举报
回复
要加上这个Picture2.AutoRedraw = True

Private Sub Form_Load()
Picture2.AutoRedraw = True
End Sub

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧