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);
image.fill(Qt::transparent);QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::TextAntialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
frame->render(&painter);
@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.
-
Hey, you can try adjusting the resolution using the QImage::scaled method after the capture and compress the image data yourself before transferring it to the remote client. This can involve creating a QPixmap, saving it to a compressed file format, and then sending the compressed file over to the client side for reconstruction. On the other hand you can use online application for jpeg image compression such https://jpegcompressor.com/ it also compress image with supporting jpeg, svg, png, webp and etc without losing their quality.