swarupa
17th March 2016, 06:10
Hi all ,
I am displaying images of size 352 x 240 and in those some are corrupted images. Now , i am trying to avoid corrupted images then what i need to do .
I have the following code
if (image.pixel(image.width() - 1, image.height() - 1) == 4286611584 &&
image.pixel(image.width() / 2, image.height() - 1) == 4286611584 &&
image.pixel(0, image.height() - 1) == 4286611584) {
val = 0; // invalid color : 4286611584 (default gray jpg)
if (val == 0) {
ui->label->setPixmap(QPixmap::fromImage(image));
}
} else {
val = 1;
if (val == 1) {
ui->label->setPixmap(QPixmap::fromImage(image));
}
}
In this they gave
image.pixel(image.width()-1,image.height()-1 ) = 4286611584
image.pixel(image.width()/2,image.height()-1 ) = 4286611584
image.pixel(0,image.height()-1 ) = 4286611584
but i am getting different values like
image.pixel(image.width()-1,image.height()-1 ) = 4278255360
image.pixel(image.width()/2,image.height()-1 ) = 4278900992
image.pixel(0,image.height()-1 ) = 4279949312
How those values are coming based on pixel or something else .
How to calculate the image size in pixels?
I am displaying images of size 352 x 240 and in those some are corrupted images. Now , i am trying to avoid corrupted images then what i need to do .
I have the following code
if (image.pixel(image.width() - 1, image.height() - 1) == 4286611584 &&
image.pixel(image.width() / 2, image.height() - 1) == 4286611584 &&
image.pixel(0, image.height() - 1) == 4286611584) {
val = 0; // invalid color : 4286611584 (default gray jpg)
if (val == 0) {
ui->label->setPixmap(QPixmap::fromImage(image));
}
} else {
val = 1;
if (val == 1) {
ui->label->setPixmap(QPixmap::fromImage(image));
}
}
In this they gave
image.pixel(image.width()-1,image.height()-1 ) = 4286611584
image.pixel(image.width()/2,image.height()-1 ) = 4286611584
image.pixel(0,image.height()-1 ) = 4286611584
but i am getting different values like
image.pixel(image.width()-1,image.height()-1 ) = 4278255360
image.pixel(image.width()/2,image.height()-1 ) = 4278900992
image.pixel(0,image.height()-1 ) = 4279949312
How those values are coming based on pixel or something else .
How to calculate the image size in pixels?