1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| QFile file(FileName);
if(!file.open(QIODevice::ReadOnly)) //On ouvre le fichier en lecture seule
{
QMessageBox::information(this, tr("Image Viewer"),
tr("Cannot Open %1.").arg(FileName));
}
else
{
// QMessageBox::information(this, tr("Image Viewer"),
// tr("File succesfull Open %1.").arg(FileName));
QDataStream in(&file);//Lecture des donnees contenues dans le fichier.
in.setByteOrder(QDataStream::LittleEndian) ;//Pour lire dans le bon ordre et avec le bon format des donnees.
in >> FileMagic >> rows >> columns >> NbFrames >> PixelTypes >> QuantLevels >> MaxSignalLevel >> MinSignalLevel >> CommentLength ;
QMessageBox::information(this, tr("Image Viewer"),
tr("the number of the File Magic is%1.").arg(FileMagic),tr("the number of the rows is%1.").arg(rows),tr("the number of the columns is%1.").arg(columns) );
QMessageBox::information(this, tr("Image Viewer"),
tr("the number of the NbFrames is%1.").arg(NbFrames) , tr("Types of the pixel in the file is%1.").arg(PixelTypes));
QMessageBox::information(this, tr("Image Viewer"),
tr("the number of the Quantization level is%1.").arg(QuantLevels) , tr("maximum value in the image is%1.").arg(MaxSignalLevel));
QMessageBox::information(this, tr("Image Viewer"),
tr("Minimum value in the image is%1.").arg(MinSignalLevel) , tr("the length of the comment is%1.").arg(CommentLength) ) ;
isize = 1500 * 1800 * 4
; //Taille de l'image en Octet.4 étant la taille d'un Octet car l'image est codé sur 4 Octet.
file.seek(128 + CommentLength) ; //Je me positionne a la fin des commentaires et au debut des pixels de l'image pour faire la lecture.
QImage uneImage(rows, columns, QImage::Format_RGB32);
QRgb value ;
for (int x = 0; x < rows; x++)
{
for (int y = 0; y < columns; y++)
{
float f;
in >> f;
//QMessageBox::information(this, tr("Image Viewer"), tr("la valeur du pixel est%1.").arg(f)) ;
value = qRgb( f , f, f );
uneImage.setPixel(x,y,value);
}
}
ui->ZoneImage->setPixmap(QPixmap::fromImage(uneImage)); |
Partager