COMException with GFLAx in a backgroundworker?

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

overlander23
Posts: 1
Joined: Tue Apr 20, 2010 6:23 pm

COMException with GFLAx in a backgroundworker?

Post by overlander23 »

Trying to get GFLAx to load a bitmap (DPX, JPG, TGA, PNG, etc) and then turn it into something I can use in GDI+.

This works:

Code: Select all

public imgBitmap as bitmap
Public Sub loadImage()
     Dim gflIMG As New GflAx.GflAx
     gflIMG.LoadBitmap(imagename)
     Dim handleTemp As IntPtr = CType(gflIMG.GetPicture.Handle, IntPtr)
     imgBitmap = CType(Image.FromHbitmap(handleTemp), Bitmap)
End Sub
But this doesn't work... throwing a COMException that says, Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) - ErrorCode=-2147418113

Code: Select all

public imgBitmap as bitmap
Private Sub backgroundLoad()
      bgw.RunWorkerAsync()
End Sub
Public Sub bgw_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgw.DoWork
      bgLoader()
End Sub
Public Sub bgLoader()
     Dim gflIMG As New GflAx.GflAx
     gflIMG.LoadBitmap(imagename)
     Dim handleTemp As IntPtr = CType(gflIMG.GetPicture.Handle, IntPtr)           '<-----  COMException IS THROWN HERE
     imgBitmap = CType(Image.FromHbitmap(handleTemp), Bitmap)
End Sub
Any ideas on why the same code would fail within a backgroundworker thread? Is there any other way of getting the bitmap form GFLAx to a standard GDI+ bitmap for onscreen painting, etc?

Thanks for any help!