QGLWidget and JPEG
-
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. -
See "QGLWidget::convertToGLFormat()":http://doc.qt.nokia.com/4.7/qglwidget.html#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?