COMException with GFLAx in a backgroundworker?
Posted: Tue Feb 08, 2011 6:53 am
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:
But this doesn't work... throwing a COMException that says, Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) - ErrorCode=-2147418113
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!
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
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
Thanks for any help!