'By Modest
1.
'
从流转换为图像
2.
Public Function StreamToPicture(ByVal Stream As IStream) As Std
Picture
3.
Dim picStream As IStream
4.
Dim lBitmap As Long
5.
Dim hBitmap As Long
6.
Dim lngGdipToken As Long
7.
Dim tPictDesc As PICTDESC
8.
Dim IID_IPicture As IID
9.
Dim oPicture As IPicture
10.
11. lngGdipToken = StartUpGDIPlus(GdiPlusVersion)
12.
13. Set picStream = Stream
14. '
从
Stream
加载
Bitmap
15. If GdipLoadImageFromStream(picStream, lBitmap) = OK Then
16. '
根据
Bitmap
创建
hBitbmp
17. If GdipCreateHBITMAPFromBitmap(lBitmap, hBitmap, 0) = O
K Then
18. With tPictDesc
19. .cbSizeOfStruct = Len(tPictDesc)
20. .picType = vbPicTypeBitmap
21. .hgdiObj = hBitmap
22. .hPalOrXYExt = 0
23. End With
24.
25. '
初始化
IPicture
26. With IID_IPicture
27. .Data1 = &H7BF80981
28. .Data2 = &HBF32
29. .Data3 = &H101A
30. .Data4(0) = &H8B
31. .Data4(1) = &HBB
32. .Data4(3) = &HAA
33. .Data4(5) = &H30
34. .Data4(6) = &HC
35. .Data4(7) = &HAB