What is the fastest way to turn a jpeg file into a QWidget?

My current code follows this: Drive> bytearray> QImage (or QPixmap)> Painter

// Step 1: disk to qbytearray
QFile file("/path/to/file");
file.open(QIODevice::ReadOnly);
QByteArray blob = file.readAll();
file.close();

// Step 2: bytearray to QImage
this->mRenderImg = new QImage();
this->mRenderImg->loadFromData(blob, "JPG");

// Step 3: render
QPainter p(this);
QRect target; // draw rectangle
p.drawImage(target, *(this->mRenderImg));

Step 1 takes 0.5 s.
Step 2 takes 3.0s - decoding jpeg - the slowest step
Step 3 takes 0.1 s

Decrypting jpeg data seems to be the slowest step. How to make it faster?

Is there a third-party library that can convert bytearray from jpeg data to bytearray from ppm, which can be loaded into QImage faster?

Btw, Using QPixmap, the same time is executed as QImage.

+3
source share
3 answers

I was able to significantly reduce the loading time of QImage using libjpeg-turbo. Here are the steps

  • 1: .jpeg filebuffer
  • 2a: tjDecompress2() filebuffer uncompressedbuffer
  • 2b: QImage(uncompressedbuffer, int width, int height, Format pixfmt) QImage
  • 3:

2a 2b 3 QImage::loadFromData()

  • PixelFormat, libjpeg tjDecompress2(), , 2b
  • width height, 2b, tjDecompressHeader2()
+2

, , . , jpegs GUI.

. , . , , , , .

SSD , . - .

, , .

, , - , " " gifs .

, jpegs google , Picasa.

Google , , , . Picasa "" , , ( ).

, jpeg , , .

, jpeg, !

, .

+1

You asked about third-party software -

ImageMagick can quickly complete this task (even with large files):

convert 1.jpg 2.jpg 3.jpg outputfilenamehere.ppm

As long as you have an open thread, you can perform numerous operations ... Hope this helps, Getta

-1
source

All Articles