Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Convert QImage to BitmapHandle
Forum Updated to NodeBB v4.3 + New Features

Convert QImage to BitmapHandle

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashokb
    wrote on 14 Jan 2015, 14:29 last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 15 Jan 2015, 07:27 last edited by
      #2

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ashokb
        wrote on 16 Jan 2015, 06:11 last edited by
        #3

        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 ?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on 16 Jan 2015, 06:49 last edited by
          #4

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

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ashokb
            wrote on 17 Jan 2015, 11:43 last edited by
            #5

            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;
            }

            Q_DECLARE_METATYPE(HBITMAP)

            class camera : public QMainWindow
            {
            Q_OBJECT

            public:
            explicit camera(QWidget *parent = 0);
            ~camera();
            @

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

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on 18 Jan 2015, 09:33 last edited by
              #6

              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.

              1 Reply Last reply
              0

              1/6

              14 Jan 2015, 14:29

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved