Hello,
I am currently using openGL to do my image drawing but I thought I would write a test program to see if I could use all QT instead. What I need to do is to display an image that is changing rapidly (up to 64 times a second). I was using glDrawPixels but once I started doing zooming and drawing lines on it, I started to have problems.
I am crashing deep in fillRect(rr.toRect(), &textureData, d); inside of QRasterPaintEngine::drawImage.
Am I approaching this wrong? Has anyone gotten this to work? I have put up a test string in the window and that appears so something can appear in my scene.
I have a class that gets created by my main.cpp and it looks like this:
imageTester
::imageTester(QWidget *parent
){
ui.setupUi(this);
m_imageScene = new ImageScene();
m_view->show();
}
imageTester::imageTester(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
m_imageScene = new ImageScene();
m_view = new QGraphicsView(m_imageScene);
m_view->show();
}
To copy to clipboard, switch view to plain text mode
Then my imageScene (derived from QGraphcisScene) starts up a timer in the constructor and when the timer goes off, it does the following:
if (m_pixmap != NULL) {
removeItem(m_pixmap);
delete m_pixmap;
m_pixmap = NULL;
}
else {
setSceneRect(0,0, w, h);
}
unsigned char* displayBuffer = getBuffer();
// inside of getBuffer: displayBuffer = (unsigned char*) (malloc ((w*h) * 3));
// and then filled with RGB values for w * h
if (displayBuffer != NULL) {
m_pixmap = addPixmap(pixmap);
m_pixmap->setVisible(true);
update();
free (displayBuffer);
}
if (m_pixmap != NULL) {
removeItem(m_pixmap);
delete m_pixmap;
m_pixmap = NULL;
}
else {
setSceneRect(0,0, w, h);
}
unsigned char* displayBuffer = getBuffer();
// inside of getBuffer: displayBuffer = (unsigned char*) (malloc ((w*h) * 3));
// and then filled with RGB values for w * h
if (displayBuffer != NULL) {
QImage* image = new QImage(displayBuffer, w, h, QImage::Format_RGB32);
QPixmap pixmap = QPixmap::fromImage(*image);
m_pixmap = addPixmap(pixmap);
m_pixmap->setVisible(true);
update();
free (displayBuffer);
}
To copy to clipboard, switch view to plain text mode
Side question: Can I free the image at the end of this method along with displayBuffer?
Thanks for any help.
Bookmarks