title: Why is QFile::size() not approximately equal to QImage::sizeInBytes()?
body: <p>I have an image file, which is labeled by windows as 40KB big in size. I want to convert this image into PDF, but after using QPdfWriter and QPainter I ended up with a 600KB PDF file. I checked some information about the image:</p>
  <p><code>File size (QFile::size()): 40528 </code><br />
  <code>Img size (QImage::size()): QSize(2479, 3508)</code><br />
  <code>Img size in bytes (QImage::sizeInBytes()): 1094496</code><br />
  <code>Image format (QImage::format()): QImage::Format_Mono</code><br />
  <code>Image depth (QImage::depth()): 1</code></p>
  <p>Why the file size is so much different than image size? Shouldn't the output PDF file take around as much space as the source image? Can I make the image smaller using Compression or different format? It looks like there is something going on during loading the image file into a QImage object. How can I prevent that? I tried saving the file as png using QImage::save() and it successfully saved it as a 35KB file. That means the problem is with writing the image to PDF.</p>
  <pre><code>void Project::convertImgToPdf()
  {
      unsigned int i;
      QString path = projectPath + &quot;/&quot; + projectName + &quot;/output/&quot;;
      QDir dir(path + &quot;/img&quot;);
      const QString fileName(path + &quot;out.pdf&quot;);
      const QPoint imageCoordinates(0,0);
      QPdfWriter pdfWriter(fileName);
      pdfWriter.setResolution(300);
      pdfWriter.setPageSize(QPageSize(QPageSize::A4));
      QPainter painter(&amp;pdfWriter);
  
      for(i=0;i&lt;dir.count()-2;i++) {
          QImage image(path + &quot;img/img&quot; + QString::number(i));
          if(i&gt;0) {
              pdfWriter.newPage();
          }
          painter.drawImage(imageCoordinates, image);
      }
  }
  </code></pre>