[INCLUDE]
GDIPlus

[API]
GlobalAlloc
GlobalLock
GlobalUnlock
GlobalFree
CreateStreamOnHGlobal
GdipLoadImageFromStream

[CODE]
Public Function GDIPlus_LoadImageFromHGlobal(ByVal hGlobal As Long) As Long
  Dim istm As IUnknown '  IStream

  If CreateStreamOnHGlobal(ByVal hGlobal, 1&, istm) = 0& Then
    If Not istm Is Nothing Then
      If UseGDIPlus Then
        If Not GdipLoadImageFromStream(ByVal ObjPtr(istm), GDIPlus_LoadImageFromHGlobal) = OK Then
          GDIPlus_LoadImageFromHGlobal = 0&
          UnUseGDIPlus
          End If
        End If
      Set istm = Nothing
      End If
    Else
    Call GlobalFree(hGlobal)
    End If
  End Function
