[INCLUDE]
GDIPlus_LoadImageFromHGlobal

[API]
GlobalAlloc
GlobalLock
GlobalUnlock
GlobalFree
RtlMoveMemory

[CODE]
Public Function GDIPlus_LoadImageFromMem(ByVal xData As Long, ByVal LenData As Long) As Long
  Dim hMem As Long
  Dim ptrMem As Long

  If Not LenData = 0& Then
    hMem = GlobalAlloc(2&, LenData)
    If Not hMem = 0& Then
      ptrMem = GlobalLock(hMem)
      If Not ptrMem = 0& Then
        Call RtlMoveMemory(ByVal ptrMem, ByVal xData, LenData)
        Call GlobalUnlock(hMem)
        GDIPlus_LoadImageFromMem = GDIPlus_LoadImageFromHGlobal(hMem)
        GoTo NoFreeMem
        End If
      Call GlobalFree(hMem)
NoFreeMem:
      End If
    End If
  End Function
