Problems with Open-Source Downloads read and

Convert QImage to BitmapHandle

  • I am using "VideoCapX" activeX in my application.
    I want to call its method which is as follows,
    Function SetBitmapOverlay (BitmapHandle As Long, x As Long, y As Long, TransColor As Long, Alpha As Long) As Long

    I have QImage and i want to pass it to this function in first parameter. The problem is i need to convert QImage to BitmapHandle and i dont know how to do it.
    I tried to pass reference of QImage itself but then it gives following error,
    QAxBase: Error calling IDispatch member SetBitmapOverlay: Type mismatch in parameter 0
    My question is how to convert QImage to bitmap handle ?

  • Qt Windows Extras (in the QtWin namespace) provides some conversions that may be useful for you. There are also other nice goodies in there.

  • I have got another problem...
    As suggested by Andre,this is how i tried,

    @QPixmap pixmap("CrossHairScaled.bmp");
    HBITMAP handle = QtWin::toHBITMAP(pixmap);
    ui->videoCapX->dynamicCall("SetBitmapOverlay(HANDLE, long, long, long)", QVariant(handle), QVariant(0), QVariant(0),QVariant(0xFFFFFF));

    And this is the error
    @'QVariant::QVariant(void*)' is private
    inline QVariant(void *) Q_DECL_EQ_DELETE;

    Dynamic call expects all inputs as QVariant and there is no method in QVariant to convert a void* into QVariant.
    So now the question is how to pass void* to dynamic call as QVariant ?

  • Did you look into QVariant::fromValue<T>(T value)

  • Hey Andre
    I looked into QVariant::fromValue<T>(T value).
    But it seems that it will not work here, since HBITMAP is a void *.
    Still i tried it like this,
    @#include <QPixmap>
    #include <QtWin>

    namespace Ui {
    class camera;


    class camera : public QMainWindow

    explicit camera(QWidget *parent = 0);

    This ends in crash. I thing this function is only for structures.
    Please correct me if i am going wrong...

  • I'm sorry, I just tried giving a pointer to some windows-specific things, but I have not used this myself, especially not in combination with activeX.

Log in to reply