End If
Case ImageFileFormat.Gif
If Not GetEncoderClsID("Image/gif", CLSID) = -1 Then'如果原始的图像是24位,则这个函数会调用系统的调色板来将图像转换为8位,转换的效果会不尽人意,但也有可能系统不自动转换,保存失败
SaveStdPicToFile = (GdipSaveImageToFile(Bitmap, StrPtr(FileName), CLSID(0), ByVal 0) = 0)
End If
End Select
End If
GdipDisposeImage Bitmap'注意释放资源
GdiplusShutdown Token '关闭GDI+ 。
End Function
Private Function GetEncoderClsID(strMimeType As String, ClassID() As Long) As Long
Dim Num As Long
Dim SizeAs Long
Dim I As Long
Dim Info()As ImageCodecInfo
Dim Buffer()As Byte
GetEncoderClsID = -1
GdipGetImageEncodersSize Num, Size '得到解码器数组的大小
If Size0 Then
ReDim Info(1 To Num) As ImageCodecInfo '给数组动态分配内存
ReDim Buffer(1 To Size) As Byte
GdipGetImageEncoders Num, Size, Buffer(1)'得到数组和字符数据
CopyMemory Info(1), Buffer(1), (Len(Info(1)) * Num) '复制类头
For I = 1 To Num '循环检测所有解码
If (StrComp(PtrToStrW(Info(I).MimeType), strMimeType, vbTextCompare) = 0) Then '必须把指针转换成可用的字符
CopyMemory ClassID(0), Info(I).ClassID(0), 16'保存类的ID
GetEncoderClsID = I'返回成功的索引值
Exit For
End If
Next
End If
End Function
Private Function PtrToStrW(ByVal lpsz As Long) As String
Dim Out As String
Dim LengthAs Long
Length = lstrlenW(lpsz)
If Length > 0 Then
Out = StrConv(String$(Length, vbNullChar), vbUnicode)
CopyMemory ByVal Out, ByVal lpsz, Length * 2
PtrToStrW = StrConv(Out, vbFromUnicode)
End If
End Function
【word右键怎么增加图片另存为 word右键怎么增加图片另存为文件】For Each cbn In Array("AutoText", "Drawing Canvas", "Organization Chart", "Diagram", "Frames", "Flowchart", "Inline Picture", "Floating Picture", "Shapes", "Inline Canvas", "Table Pictures", "AutoShapes", "Basic Shapes", "Insert Shape", "Picture", "WordArt Context Menu", "WordArt")
推荐阅读
- 5个月宝宝能吃肉沫吗?
- cf中秋庆节活动地址2021 穿越火线中秋活动礼包领取地址20201
- Word怎么制作简历 word怎么制作epub
- 植物大战僵尸通关技巧?
- 桑黄菌的种植技术及条件 桑黄菌的种植技术
- 爆笑段子,怎样形容女孩子长得漂亮?
- 图片素材网站排行榜 高清素材图片的网站
- 植物大战僵尸两排搭梯能打无尽吗?
- 面容id不可用稍后尝试什么意思 面容id不可用稍后尝试什么意思呀