Important: Please read the Qt Code of Conduct -

QGLWidget and JPEG

  • Hello!
    I need to view JPEG from IP-camera. My code:
    @QByteArray jpg;
    GLuint texture;
    QSize frame_resolution;@
    resizeGL(int width, int height)
    @texture = bindTexture(QImage::fromData(jpg));@
    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.

  • Moderators

    See "QGLWidget::convertToGLFormat()":

  • 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?

  • Moderators

    Are you calling


    in your code?

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

Log in to reply