关于图象的保存问题(VB 6.0)

ladofwind 2001-01-23 03:11:00
关于图象的保存问题(VB 6.0)
请问如何用savepicture语句保存picturebox中的图像,书上说
savepicture object.picture, filename 我试了一下,不行,但把
语句改为savepicture object.image,filename 反倒可以,但保存的
总是picture属性中的图像,我想保存我自己画的图象总不成功,请
高手们指点。感谢了!
...全文
281 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
nostoryboy 2001-02-01
  • 打赏
  • 举报
回复
用OLE里面装个画笔
xxlroad 2001-01-29
  • 打赏
  • 举报
回复
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6495
ClientLeft = 60
ClientTop = 345
ClientWidth = 8235
LinkTopic = "Form1"
ScaleHeight = 6495
ScaleWidth = 8235
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture1
Height = 5085
Left = 240
ScaleHeight = 5025
ScaleWidth = 7950
TabIndex = 1
Top = 735
Width = 8010
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 4965
TabIndex = 0
Top = 30
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
'函数:
Sub ScrnCap(Lt, Top, Rt, Bot)
rWidth = Rt - Lt
rHeight = Bot - Top
SourceDC = CreateDC("DISPLAY", 0, 0, 0)
DestDC = CreateCompatibleDC(SourceDC)
BHandle = CreateCompatibleBitmap(SourceDC, rWidth, rHeight)
SelectObject DestDC, BHandle
BitBlt DestDC, 0, 0, rWidth, rHeight, SourceDC, Lt, Top, &HCC0020
Wnd = Screen.ActiveForm.hwnd
OpenClipboard Wnd
EmptyClipboard
SetClipboardData 2, BHandle
CloseClipboard
DeleteDC DestDC
ReleaseDC DHandle, SourceDC
End Sub
'以下的示例把屏幕图象捕捉后,放到Picture1 中。
Sub Command1_Click()
Form1.Visible = False
ScrnCap 0, 0, 640, 480
Form1.Visible = True
Picture1 = Clipboard.GetData()
End Sub

xxlroad 2001-01-29
  • 打赏
  • 举报
回复
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7140
ClientLeft = 60
ClientTop = 345
ClientWidth = 7950
LinkTopic = "Form1"
ScaleHeight = 7140
ScaleWidth = 7950
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
Height = 3015
Left = 1395
ScaleHeight = 2955
ScaleWidth = 2520
TabIndex = 0
Top = 1920
Width = 2580
Begin VB.Shape Shape1
Height = 1155
Left = 360
Top = 600
Width = 1485
End
Begin VB.Line Line1
X1 = -765
X2 = 1305
Y1 = 765
Y2 = -210
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Click()
' 声明变量。
Dim CX, CY, Limit, Radius As Integer, Msg As String
ScaleMode = vbPixels ' 设置比例模型为像素。
AutoRedraw = True ' 打开 AutoRedraw。
Width = Height ' 改变宽度以便和高度匹配。
CX = ScaleWidth / 2 ' 设置 X 位置。
CY = ScaleHeight / 2 ' 设置 Y 位置。
Limit = CX ' 圆的尺寸限制。
For Radius = 0 To Limit ' 设置半径。
Picture1.Circle (CX, CY), Radius, RGB(Rnd * 255, Rnd * 255, Rnd * 255)
DoEvents ' 转移到其它操作。
Next Radius
Msg = "Choose OK to save the graphics from this form "
Msg = Msg & "to a bitmap file."
MsgBox Msg
SavePicture Picture1.Image, "TEST.BMP" ' 将图片保存到文件。
End Sub
cloud_soft 2001-01-25
  • 打赏
  • 举报
回复
GZ
TechnoFantasy 2001-01-23
  • 打赏
  • 举报
回复
简单的通过SavePicture保存PictureBox中的图像是不行的,需要使用API以及接口
http://www.applevb.com/sourcecode/capture.zip
这个程序可以参考一下,是一个屏幕捕捉以及保存的程序
www.applevb.com

7,765

社区成员

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

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