Hi, I'm new to Qt4. I'm currentl using Qt as part of my project, but I'm facing problem using it. My project consist of reading a raw image, and then display it.
Since my raw image is in short byte array, I can't seems to show the image correctly using QImage. However, I manage to get the image to output correctly with OpenGL glDrawPixels, but the process is kinda sluggish and eats quite a lot of resources. Since I just wanna show the image, I was searching for a better way.
Here's my OpenGL code.
void pktGLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDrawPixels(imgWidth, imgHeight, GL_LUMINANCE, GL_BYTE, glBuffer);
glFlush();
}
void pktGLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDrawPixels(imgWidth, imgHeight, GL_LUMINANCE, GL_BYTE, glBuffer);
glFlush();
}
To copy to clipboard, switch view to plain text mode
And here's my QImage code, which can't seems to work properly.
void pktQImage2D::processBuffer()
{
m_Image
= QImage((uchar
*) pixelData, imgWidth, imgHeight,
QImage::Format_Mono);
}
void pktQImage2D::processBuffer()
{
m_Image = QImage((uchar *) pixelData, imgWidth, imgHeight, QImage::Format_Mono);
}
To copy to clipboard, switch view to plain text mode
Bookmarks