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. QGLWidget and JPEG
Qt 6.11 is out! See what's new in the release blog

QGLWidget and JPEG

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.2k 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.
  • D Offline
    D Offline
    debian
    wrote on last edited by
    #1

    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
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      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
      0
      • D Offline
        D Offline
        debian
        wrote on last edited by
        #3

        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
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          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
          0
          • D Offline
            D Offline
            debian
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

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