Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QGLWidget and JPEG

    General and Desktop
    2
    5
    3659
    Loading More Posts
    • 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.
    • D
      debian last edited by

      Hello!
      I need to view JPEG from IP-camera. My code:
      @QByteArray jpg;
      GLuint texture;
      QSize frame_resolution;@
      initializeGL()
      @qglClearColor(Qt::black);@
      resizeGL(int width, int height)
      @texture = bindTexture(QImage::fromData(jpg));@
      paintGL()
      @drawTexture(QRectF(-frame_resolution.width()/2,
      -frame_resolution.height()/2,
      frame_resolution.width(),
      frame_resolution.height()),
      texture);@
      I successfully get JPEG from camera, but I see only grey rectangle.

      Ok, I try check this function with local image, but I get strange result:
      @texture = bindTexture(QImage("/tmp/test.jpg"));@
      I view brown rectangle.
      @texture = bindTexture(QString("/tmp/test.jpg"));@
      I view white rectangle.

      My question - how can I see JPEG with QGLWidget and OpenGL.
      Thank you and excuse me for my bad english.

      1 Reply Last reply Reply Quote 0
      • M
        mlong last edited by

        See "QGLWidget::convertToGLFormat()":http://doc.qt.nokia.com/4.7/qglwidget.html#convertToGLFormat.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply Reply Quote 0
        • D
          debian last edited by

          bq. QImage QGLWidget::convertToGLFormat ( const QImage & img ) [static]
          Converts the image img into the unnamed format expected by OpenGL functions such as glTexImage2D(). The returned image is not usable as a QImage, but QImage::width(), QImage::height() and QImage::bits() may be used with OpenGL. The GL format used is GL_RGBA.

          Why if I don't use glTexImage2D and etc or bindTexture don't convert image?

          1 Reply Last reply Reply Quote 0
          • M
            mlong last edited by

            Are you calling

            @
            glEnable(GL_TEXTURE_2D);
            @

            in your code?

            Software Engineer
            My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

            1 Reply Last reply Reply Quote 0
            • D
              debian last edited by

              I post all code. I think what I don't need mixture OpenGL and Qt functions.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post