I see some problems with your LoadImage() code snippet:
(1) The images list will contain only one image and it will contain bogus or a trash. The variable b is set to 1 (use bool for it), then the image is appended to the list, then it is filled by pixels and then the while cycle is exited. imageNumber should be 1 and the images list will contain the image before filling.
(2) Reading the data values is shifted. C++ fields are indexed starting from zero, therefore
colors=qRgb(data.value(0),data.value(1),data.value(2));
colors=qRgb(data.value(0),data.value(1),data.value(2));
To copy to clipboard, switch view to plain text mode
(supposing the data contain RGB triplets. If they are ARGB then, really, data(1), data(2), data(3) but you need to remove 4 bytes).
(3) The removeFirst() method can be really expensive. I suggest:
int k = 0;
for( int i = 0; i < getHeight(); i++ )
{
for( int j = 0; j < getWidth(); j++ )
{
colors=qRgb(data.value(k),data.value(k+1),data.value(k+2));
a.setPixel(j,i,colors);
k += 3;
}
}
int k = 0;
for( int i = 0; i < getHeight(); i++ )
{
for( int j = 0; j < getWidth(); j++ )
{
colors=qRgb(data.value(k),data.value(k+1),data.value(k+2));
a.setPixel(j,i,colors);
k += 3;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks