Qt World Summit: Submit your Presentation

Reducing size of captured images.

  • hi,
    I am capturing the image of a webpage using the code
    @ QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied);

    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setRenderHint(QPainter::TextAntialiasing, true);
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);

    But sometimes the size of the image captured greater than 1MB.I am transfering these captured images to a remote client.How can i reduce the size of the captured images.

  • Well, the size depends on the resolution of the picture and on the chosen format. If you want to minimise the picture size, you'd better use jpeg format. Reducing the pixel format may also help if you don't need a 32 bits depth, for instance 24-bits colour depth seems fairly decent to me.

  • Is there any other method to reduce the size.I tried both saving the file in jpeg and QImageFormat to 24 bits per depth but both does not significantly reduce the size.Is ther any method to reduce the resolution of the captured image?

  • Sure, you can use the QImage::scaled method to reduce the resolution once the capture has been made.

  • You could compress the contents of the image yourself, send the compressed data stream and re-build the Image on the client side.

    You could make a QPixmap out of it, save it to a temporary file of a compressed type, and transfer that file.

Log in to reply