0

I have created a qt project that take screen shot of the desktop and compress it .As far as I have taken the screen shot and scaled it.The original screen shot is about 230kb size and while scaling it reduced up-to 60kb.My problem is I need to reduce the saved jpg to around 5-10kb size without loosing it's clarity of the image.I have searched for the libraries and add-on in Qt but couldn't find any one that could give the possible result Is there any algorithms ,examples or compression techniques that could reduce the size drastically without loosing its clarity? OS:Ubuntu 14.04, qt-5.2.1 .Here given below code I have done so far:

 int widthToScale= (QApplication::desktop()->screenGeometry().width()*60)/100;
int heightToScale=(QApplication::desktop()->screenGeometry().width()*60)/100;

QPixmap p=QPixmap::grabWindow(QApplication::desktop()->winId(),0,0,
                              QApplication::desktop()->screenGeometry().width(),
                              QApplication::desktop()->screenGeometry().height()).scaled(widthToScale,heightToScale,Qt::KeepAspectRatio,Qt::SmoothTransformation);

p.save(localpath,0,65);
Dev
  • 95
  • 1
  • 12
  • 1
    The only thing you can do is to experiment with compression level. In some cases format may also help. Another idea would be to reduce number of colors from 24/32 bits to 16 or even 8. – Michał Walenciak Jan 28 '15 at 12:19
  • Thanks a lot for the advice .I am new to qt ,in that case how to reduce number of colors from 24/32 bits to 16 or even 8. – Dev Jan 28 '15 at 12:25
  • convert `QPixmap` to `QImage` with `QPixmap::​toImage()` and then use `QImage::convertToFormat` with proper `QImage::Format`. `QImage` also has `save` member as `QPixmap`. use it for saving it as you do it now – Michał Walenciak Jan 28 '15 at 13:12
  • I have tired the solution you advised.Even if I tried it I am getting the image reduced as 60kb where I have used QImage::Format_RGB16,Qt::AutoColor for format conversion .But I need to convert to at least 10kb. – Dev Jan 29 '15 at 07:44
  • Nothing more I can help you. You need to experiment, In some cases PNG may do better work, but it depends on details of your image. Try to go down with quality. – Michał Walenciak Jan 29 '15 at 12:16

0 Answers0