怎样将 picturebox中的图形输出为jpg格式文件

rkdrc 2010-05-05 09:45:39
是否有函数或方法能将picturebox中的图形输出为jpg格式文件导出来
...全文
81 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
贝隆 2010-05-06
  • 打赏
  • 举报
回复
of123,学习了!
chinaboyzyq 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 of123 的回复:]

' ----==== API Declarations ====----

Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type

Private Type GdiplusStartupInput
Gdipl……
[/Quote]
很好用……
hizhfei 2010-05-06
  • 打赏
  • 举报
回复
怎么看不了5楼的啊 ?

of123 2010-05-06
  • 打赏
  • 举报
回复
' ----==== API Declarations ====----

Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type

Private Type GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type

Private Type EncoderParameter
GUID As GUID
NumberOfValues As Long
type As Long
Value As Long
End Type

Private Type EncoderParameters
Count As Long
Parameter As EncoderParameter
End Type

Private Declare Function GdiplusStartup Lib "GDIPlus" ( _
token As Long, _
inputbuf As GdiplusStartupInput, _
Optional ByVal outputbuf As Long = 0) As Long

Private Declare Function GdiplusShutdown Lib "GDIPlus" ( _
ByVal token As Long) As Long

Private Declare Function GdipCreateBitmapFromHBITMAP Lib "GDIPlus" ( _
ByVal hbm As Long, _
ByVal hpal As Long, _
Bitmap As Long) As Long

Private Declare Function GdipDisposeImage Lib "GDIPlus" ( _
ByVal Image As Long) As Long

Private Declare Function GdipSaveImageToFile Lib "GDIPlus" ( _
ByVal Image As Long, _
ByVal Filename As Long, _
clsidEncoder As GUID, _
encoderParams As Any) As Long

Private Declare Function CLSIDFromString Lib "ole32" ( _
ByVal str As Long, _
id As GUID) As Long

' ----==== SaveJPG ====----

Public Sub SaveJPG( _
ByVal pict As StdPicture, _
ByVal filename As String, _
Optional ByVal quality As Byte = 80)
Dim tSI As GdiplusStartupInput
Dim lRes As Long
Dim lGDIP As Long
Dim lBitmap As Long

' Initialize GDI+
tSI.GdiplusVersion = 1
lRes = GdiplusStartup(lGDIP, tSI)

If lRes = 0 Then

' Create the GDI+ bitmap
' from the image handle
lRes = GdipCreateBitmapFromHBITMAP(pict.Handle, 0, lBitmap)

If lRes = 0 Then
Dim tJpgEncoder As GUID
Dim tParams As EncoderParameters

' Initialize the encoder GUID
CLSIDFromString StrPtr("{557CF401-1A04-11D3-9A73-0000F81EF32E}"), _
tJpgEncoder

' Initialize the encoder parameters
tParams.Count = 1
With tParams.Parameter ' Quality
' Set the Quality GUID
CLSIDFromString StrPtr("{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}"), .GUID
.NumberOfValues = 1
.type = 4
.Value = VarPtr(Quality)
End With

' Save the image
lRes = GdipSaveImageToFile( _
lBitmap, _
StrPtr(Filename), _
tJpgEncoder, _
tParams)

' Destroy the bitmap
GdipDisposeImage lBitmap

End If

' Shutdown GDI+
GdiplusShutdown lGDIP

End If

If lRes Then
Err.Raise 5, , "Cannot save the image. GDI+ Error:" & lRes
End If

End Sub
rkdrc 2010-05-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 syssz 的回复:]
用VB net
[/Quote]
这个真不会
SYSSZ 2010-05-06
  • 打赏
  • 举报
回复
用VB net
threenewbee 2010-05-06
  • 打赏
  • 举报
回复
VB不支持,需要第三方的库。
ynchenlong 2010-05-06
  • 打赏
  • 举报
回复
SavePicture 控件名称.Picture, 保存文件名

7,789

社区成员

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

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