What's the fastest way to show JPG/JPEG images
-
@R_Irudezu No need to create QFile instance to delete a file, use http://doc.qt.io/qt-5/qfile.html#remove-1 instead.
Use QDir::NoDotAndDotDot in QDirIterator it("/framesPath", QDirIterator::Subdirectories); and remove these two it.next().
I'm not sure why you create a QImage first and then QPixmap. You can scale QPixmap as well: http://doc.qt.io/qt-5/qpixmap.html#scaled -
@R_Irudezu said in What's the most efficient way to use QLabel as video player:
I said "I have to do it in this way. Because i'm manipulating frames with another program."
Yes, but perhaps that other program supports sending the data through a pipe. Or you have some influence on that program and can request streaming support to be added. Et cetera
-
this is of course untested. And as the comment says, you have to modfy the QbyteArray to actually get the rgb(a) values you want. You'll have too look that one up. Also the memberImage needs to have the same size as the images you want to load.
void myWidget::showFrames() { QDirIterator it("/framesPath", QDir::NoDotAndDotDot, QDirIterator::Subdirectories); memberQFile.setFileName(it.next()); if(memberQFile.exists() && memberQFile.open(QIODevice::ReadOnly)){ QByteArray data = memberQFile.readAll(); //This will fail, the QByteArray has to be trimmed/changed according to img file/header memcpy(memberImage.bits(),data.data(), data.size()); memberQFile.remove();//Also automatically closes the file update();//request repaint } } void myWidget::paintEvent(QPaintEvent *event) { QWidget::paintEvent(event); QPainter p(this); p.drawImage(rect(),memberImage, memberImage.rect()); }
-
There are no efficient way with QLabel.
-
Hi,
Jpeg decompression is expensive. What size are you images ? What quality ? And to what application are you going to send them ?
You might want to consider using turbo-jpeg to handle the decompression.
-
@SGaist I'm receiving jpeg data and decoding it with GDI+ in quality of between 30-50 (with a native c++ compiled .exe file)
long quality = 50; encoderParameters.Parameter[0].Value = &quality;
All images save under a directory. I don't want to use any other decompress handling. Images are about 30-50 Kb and i just want to show them in a Qt item. (QLabel is very useless for this). All images will be shown with a QTimer (40 ms) and will be deleted.
-
Where are you getting these images from in the first place ?
-
@SGaist I'm getting images from a .exe program written in C. The C program connects a camera, getting images, manipulate them with GDI+ and save them under a specific directory. The program uses some libraries, these libraries are not compatible with any of Qt versions.
-
Why are they not ?