PDA

View Full Version : removedddddd



PatrickGezzi
15th December 2013, 15:01
#####removed#####

anda_skoa
15th December 2013, 18:33
Just to be sure: the file you are reading was written using QDataStream, right?

Have you tried writing the read image to disk? I.e. calling a.save() after the two loops?

Cheers,
_

Radek
15th December 2013, 18:57
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));

(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.val ue(k+2));
a.setPixel(j,i,colors);
k += 3;
}
}