PDA

View Full Version : QTWebPage and how to get the size of an image url for rendering



eric_vi
16th September 2010, 19:47
i am trying to render a web page into a file

according to the documentation... you need to set the viewport size with the page.MainFrame() size...

my problem is that if the url is an image document such as a simple jpg or png there is no such thing and page.MainFrame()->contentsSize() is (0,0)!



page.setViewportSize(page.mainFrame()->contentsSize());

QImage image(page.viewportSize(), QImage::Format_ARGB32);
QPainter painter(&image);



so the question is... if i have an url to a picture that is displayed by the renderer without any mainframe around, how can i collect the pixel size of this image document? The QTWebView displays the pixel size in the title so there should be a way to get this info


Thank you for your help

tbscope
16th September 2010, 19:55
The size is probably in the header.

If not, you need to download the complete image (or partial depending on the format)

eric_vi
16th September 2010, 20:16
hello thank you, well what do you mean header? if you mean the picture header, well i have no problem figuring out the size of the picture if i download it. But i want to avoid that and just collect the size of this image document in the same manner than the QTWebView does