Talei
12th November 2010, 06:54
Hello,
I have a small problem with the performance of my pixel manipulation approach.
Currently I use something like this:
QImage img;
int valR = 0, value = 0;
for( int i = 0; i < img.height(); ++i)
{
QRgb *scL = reinterpret_cast< QRgb *>( img.scanLine( i ) );
for( int j = 0; j < img.width(); ++j)
{
valR = qRed(scL[j]) + value;
scL[j] = qRgb( valR, valG, valB );
}
}
to access pixel data to manipulate.
I use this code to show "preview" and I can see, while changing slider (connected to the value), that image changes not as fast as i.e. Photoshop (practically real time preview) or Gimp (little slower then PH but much faster then this). (I know that Ph probably use threads to utilize full cpu power, but even with my old cpu with only 1 core speed is much faster).
Basically what I do is:
1. load the data
2. cpy data to QImage tmp
3. manipulate
4. change to QPixmap
5. setPixmap on the QLabel
Test shows me that execution is around 15-30ms for these 5 steps above so in theory I should have a smooth colour change while moving slider. (qDebug of time.elapsed). But that's don't happens (even with signal blocking for slider while this code execute).
The question is what can cause such lag?
Any suggestion are more then welcome.
Best regards
PS. sorry if this is wrong forum to post such a question.
I have a small problem with the performance of my pixel manipulation approach.
Currently I use something like this:
QImage img;
int valR = 0, value = 0;
for( int i = 0; i < img.height(); ++i)
{
QRgb *scL = reinterpret_cast< QRgb *>( img.scanLine( i ) );
for( int j = 0; j < img.width(); ++j)
{
valR = qRed(scL[j]) + value;
scL[j] = qRgb( valR, valG, valB );
}
}
to access pixel data to manipulate.
I use this code to show "preview" and I can see, while changing slider (connected to the value), that image changes not as fast as i.e. Photoshop (practically real time preview) or Gimp (little slower then PH but much faster then this). (I know that Ph probably use threads to utilize full cpu power, but even with my old cpu with only 1 core speed is much faster).
Basically what I do is:
1. load the data
2. cpy data to QImage tmp
3. manipulate
4. change to QPixmap
5. setPixmap on the QLabel
Test shows me that execution is around 15-30ms for these 5 steps above so in theory I should have a smooth colour change while moving slider. (qDebug of time.elapsed). But that's don't happens (even with signal blocking for slider while this code execute).
The question is what can cause such lag?
Any suggestion are more then welcome.
Best regards
PS. sorry if this is wrong forum to post such a question.