求VB图形转换程序代码,注意:要代码

一百多行就可以了,,,,高手速度啊.....随便什么格式转换成任意图片的格式都行...... 一百多行就可以了,,,,高手速度啊.....
随便什么格式转换成任意图片的格式都行...
展开
 我来答
网海1书生
科技发烧友

2009-12-09 · 擅长软件设计、WEB应用开发、小程序
网海1书生
采纳数:12311 获赞数:26230

向TA提问 私信TA
展开全部
你要说清楚,要什么格式的图片转换成什么格式的图片,如果要转换所有的图片格式,那么1000行代码可能也不行,除非是调用其他软件。。。不过这样就直接用其他软件算了
百度网友27862d5
2009-12-13 · TA获得超过785个赞
知道大有可为答主
回答量:387
采纳率:50%
帮助的人:434万
展开全部
这是 BMP图像转 JPG图像的程序,Picture1 加载将要转换的 BMP图像,Picture2 显示的是转换后的 JPG的图像。。。。

Option Explicit
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, ByVal outputbuf As Long) 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
Private Declare Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal filename As Long, Bitmap As Long) As Long

Private Sub Command1_Click()
Dim ret As Boolean

' Picture1.Picture = LoadPicture("C:\a.bmp") '打开要压缩的图片

ret = PictureBoxSaveJPG(Picture1, "C:\b.jpg") '保存压缩后的图片
If ret = False Then
MsgBox "保存失败"
Else
MsgBox "保存在C:\b.jpg"
End If
Picture2.Picture = LoadPicture("C:\b.jpg") '打开要压缩的图片
End Sub

Private Function PictureBoxSaveJPG(ByVal pict As StdPicture, ByVal filename As String, Optional ByVal quality As Byte = 80) As Boolean
Dim tSI As GdiplusStartupInput
Dim lRes As Long
Dim lGDIP As Long
Dim lBitmap As Long

'初始化 GDI+
tSI.GdiplusVersion = 1
lRes = GdiplusStartup(lGDIP, tSI, 0)

If lRes = 0 Then
'从句柄创建 GDI+ 图像
lRes = GdipCreateBitmapFromHBITMAP(pict.Handle, 0, lBitmap)

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

'初始化解码器的GUID标识
CLSIDFromString StrPtr("{557CF401-1A04-11D3-9A73-0000F81EF32E}"), tJpgEncoder

'设置解码器参数
tParams.Count = 1
With tParams.Parameter ' Quality
'得到Quality参数的GUID标识
CLSIDFromString StrPtr("{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}"), .GUID
.NumberOfValues = 1
.type = 4
.Value = VarPtr(quality)
End With

'保存图像
lRes = GdipSaveImageToFile(lBitmap, StrPtr(filename), tJpgEncoder, tParams)

'销毁GDI+图像
GdipDisposeImage lBitmap
End If

'销毁 GDI+
GdiplusShutdown lGDIP
End If

If lRes Then
PictureBoxSaveJPG = False
Else
PictureBoxSaveJPG = True
End If
End Function

参考资料: http://sphyj.blog.163.com/blog/static/6609646200982521526215/

本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
红衣老大之一
2009-12-09 · TA获得超过365个赞
知道小有建树答主
回答量:767
采纳率:0%
帮助的人:409万
展开全部
大哥 代码不是论行的

即便是论行 也是越少越好
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
ccy_5242
2009-12-09
知道答主
回答量:9
采纳率:0%
帮助的人:0
展开全部
4787787
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式