Needing Help with the GFl-Active X ... basic stuff

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

Moderators: XnTriq, xnview

Post Reply
sonhospa
Posts: 2
Joined: Sat Oct 04, 2008 6:48 pm
Location: Munich

Needing Help with the GFl-Active X ... basic stuff

Post by sonhospa » Sat Oct 04, 2008 7:29 pm

Hello,

I'm trying to use the ActiveX Object enclosed with the GflSDK in Visual Basic 2008 (.NET), to which I have to admit I'm pretty new... so that I stay close to the helpfile anyway. But still: when I want to assign the object to a PictureBox on a form (:arrow: MyImage.LoadBitmap(fileToDisplay), then :arrow: frmHead.pbox.Image = MyImage.GetPicture), VB throws an InvalidCastException: COM Object of type "System.__COMObject" can't be converted to class type "System.Drawing.Image".

In a frequented developers forum I got the following advice: "Your code is trying to convert an object of type GflAx to a .NET Image object. That's not going to work. The GflAx object has to expose some method to return an Image object." Having assumed the LoadBitmap and GetPicture methods would return an image object, I'm confused about what I'm doing now... what did I do wrong?

Would you please be so kind as to lead me out of the trap :?

Thank you so much,
regards
Michael

minime
Posts: 1
Joined: Fri Oct 17, 2008 2:21 pm

Post by minime » Fri Oct 17, 2008 2:29 pm

i download the sdk today too and had the same problem.
u have to convert the IPicture format.

create this class :

Code: Select all

    Private NotInheritable Class myClass
        Inherits System.Windows.Forms.AxHost
        Public Shared Shadows Function GetPictureFromIPicture(ByVal picture As Object) As Image
            Return AxHost.GetPictureFromIPicture(picture)
        End Function
    End Class
use it like this :

Code: Select all

        Dim pic As Bitmap = MyClass.GetPictureFromIPicture(GflAxObj.GetPicture)

sonhospa
Posts: 2
Joined: Sat Oct 04, 2008 6:48 pm
Location: Munich

Post by sonhospa » Sat Oct 18, 2008 6:05 am

Thank you for your answer and the code snippet, minime!
I'll try it out asap. Have a nice weekend.

Post Reply