×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    5

    Snapshot of HTML page with flash contents

    Hi,

    I am trying to display/capture snapshot of HTML page with flash contents. While searching on net found a utility called CutyCapt which captures a snapshot of web page. I tried that utility and found that it captures the snapshot of webpage.

    However, it doesn't capture the flash contents in a web page. I am using http://www.flashiness.com/fseyeball.htm as a test case. It has eyeball flash content and a blue box with "flashiness.com" text in it.

    When I ran the CutyCapt utility on this page (CutyCapt.exe --url=http://www.flashiness.com/fseyeball.htm --out=test.png), the output snapshot was showing blank in the places where there is flash content.

    Later I came to know that we have to use option --plugins=on to capture the flash content. I went through the code and saw that, QWebSettings::PluginsEnabled is set to true to enable plugins. I used this option but still the flash contents were not captured properly.

    Also, running the CutyCapt multiple seems to give the snapshot of the same page, I mean I don't find any difference in the output though the HTML page has GIF content in it.

    Would anybody here please help me in getting the flash contents captured properly.

    I tried the Qt demo browser that we get with SDK, the browser displays the flash contents of the above mentioned page properly. I saw the code of the demo browser and found that it also just sets the same attribute QWebSettings::PluginsEnabled to true to enable plugins. If I disable this line then the browser doesn't display the flash contents.

    But why is that on setting the same attribute in CutyCapt or anu other sample code that captures a webpage as a file doesn't capture the flash contents?

    Please help me getting this resolved.

    Thanks in advance.

    PS: I wanted to attach the sanpshot, but couldn't find option for attachments.

  2. #2
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Snapshot of HTML page with flash contents

    The flash content is not rendered by Qt at all. Flash plug-in is embedded on the webpage.. that's why you cannot see it on your screenshots.
    Did you try to use something like this: QPixmap::grabWindow(QApplication::desktop()->winId())?

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    5

    Re: Snapshot of HTML page with flash contents

    Hi,

    Sorry I didn't get you. I am bit new to to Qt and am interested in implementing an application that uses QtWebkit as a renderer engine to capture snapshot of webpage (HTML/flash).

    What I know is Qt uses QtWebkit module for web rendering and QTWebkit does support flash content rendering through plugin. Similar to CutyCapt we have IECapt utility which does the same job (capture snapshot of a webpage and save it as a file). It captures the flash content properly but not the CutyCapt.

    I feel something is missing in CutyCapt because of which flash content is not being captured. Below is the code of Snapshot capture code of CutyCapt utility.

    void
    CutyCapt::saveSnapshot() {
    QWebFrame *mainFrame = mPage->mainFrame();
    QPainter painter;
    const char* format = NULL;

    for (int ix = 0; CutyExtMap[ix].id != OtherFormat; ++ix)
    if (CutyExtMap[ix].id == mFormat)
    format = CutyExtMap[ix].identifier; //, break;

    // TODO: sometimes contents/viewport can have size 0x0
    // in which case saving them will fail. This is likely
    // the result of the method being called too early. So
    // far I've been unable to find a workaround, except
    // using --delay with some substantial wait time. I've
    // tried to resize multiple time, make a fake render,
    // check for other events... This is primarily a problem
    // under my Ubuntu virtual machine.

    mPage->setViewportSize( mainFrame->contentsSize() );

    switch (mFormat) {
    case SvgFormat: {
    QSvgGenerator svg;
    svg.setFileName(mOutput);
    svg.setSize(mPage->viewportSize());
    painter.begin(&svg);
    mainFrame->render(&painter);
    painter.end();
    break;
    }
    case PdfFormat:
    case PsFormat: {
    QPrinter printer;
    printer.setPageSize(QPrinter::A4);
    printer.setOutputFileName(mOutput);
    // TODO: change quality here?
    mainFrame->print(&printer);
    break;
    }
    case RenderTreeFormat:
    case InnerTextFormat:
    case HtmlFormat: {
    QFile file(mOutput);
    file.open(QIODevice::WriteOnly | QIODevice::Text);
    QTextStream s(&file);
    s.setCodec("utf-8");
    s << (mFormat == RenderTreeFormat ? mainFrame->renderTreeDump() :
    mFormat == InnerTextFormat ? mainFrame->toPlainText() :
    mFormat == HtmlFormat ? mainFrame->toHtml() :
    "bug");
    break;
    }
    default: {
    mainFrame = mPage->mainFrame();
    QImage image(mPage->viewportSize(), QImage::Format_ARGB32);
    painter.begin(&image);
    mainFrame->render(&painter);
    painter.end();
    //mOutput = QString("file%1.png").arg(i);
    //strcat(mOutput.toStdString().c_str(),i);
    // TODO: add quality
    image.save(mOutput, format);

    }
    };
    }

    The utility has a command line option --plugins which on setting to 'on' sets the attribute QWebSettings::PluginsEnabled to true.
    The link for the utility is as below
    http://cutycapt.sourceforge.net/

    Please do the needful.

  4. #4
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Snapshot of HTML page with flash contents

    QWebkit renders the HTML but NOT the flash content... this means you cannot capture the flash content in this way.
    indeed, mainFrame->render(&painter) leaves a blank area. This area will be drawn later by the flash plugin.

    To take a snapshot of the html + the embedded flash widget you need QPixmap::grabWindow and then crop the image using the webview's global coordinates.

  5. #5
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Snapshot of HTML page with flash contents

    What is your platform? On Symbian the simplest thing to do is to use a screen capture utility like ScreenShot. On Windows you can of course use "print screen" (Alt-PrtSc in the window you want, then paste into Paint or another graphic utility).

  6. #6
    Registered User
    Join Date
    Aug 2010
    Posts
    5

    Re: Snapshot of HTML page with flash contents

    Thanks for the reply.

    I am developing my application for Windows and Linux platforms. The project I am working on involves off screen rendering wherein we have to capture the content (HTML/flash) of the content server at X fps and pass it on to a buffer of a dll which will take care of the display part.
    For this I thought CutyCapt would serve as a reference for my implementation and hence started experimenting with it. It captures the HTML page but not the flash content. I have to try what 'gnuton' has suggested. Pointer to any samples using QPixmap::grabWindow would be really helpful.

    One more thing I noticed in the CutyCapt page is the below statement
    "
    Status
    CutyCapt has a number of known quirks, most of which are caused by problems with Qt and/or WebKit. For example, while plugin support can be enabled, and the plugins execute properly, their rendering cannot be captured on some platforms. Use of with caution.
    "
    Does this mean, Qt/and or webkit has a limitation for capturing contents that are rendered through plugin? Please clarify this doubt.

  7. #7
    Registered User
    Join Date
    Aug 2010
    Posts
    5

    Re: Snapshot of HTML page with flash contents

    Hi,

    I even tried using QPixmap::grabWindow(QApplication::desktop()->winId()) to capture the contents (as shown below) but even with this I am not able to capture the flash contents.

    QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(),0,0,-1,-1);
    painter.begin(&pixmap);
    mainFrame->render(&painter);
    painter.end();
    QString file("file_Trial1.png");
    pixmap.save( file, "PNG", -1 );

    The output shows blank wherever flash content is supposed to be there.

  8. #8
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Snapshot of HTML page with flash contents

    I'm not surprised. It may not be possible to capture the Flash content.

  9. #9
    Registered User
    Join Date
    Aug 2010
    Posts
    5

    Re: Snapshot of HTML page with flash contents

    So, does it mean that
    - there is no way we can capture the flash contnents using Qt/QtWebKit?
    - If yes, it means that off-screen rendering of web content having flash (copying it to memory instead of rednering it on to window) is not possibe with Qt? Is it?

    Please clarify these doubts. Depending on this I have to look for alternative other than Qt for doing my assignment.
    Plese do the needful.

  10. #10
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Snapshot of HTML page with flash contents

    I'm just thinking of similar scenarios on desktop systems. Often the integration of some animation/video graphics elements is done at a very low level where there's no screen buffer to "capture"

  11. #11
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Snapshot of HTML page with flash contents

    The code is wrong.. that's why you have still the same problem!
    You are doing exactly what you did before.

    This is what your code does:
    1) take a snapshot of the screen, which contains what you want.
    2) then you overwrite the pixmap with webkit rendered pixmap.. which does not render flash content!

    This code works:
    QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
    pimap.save("mypicture.jpg");

    Here a little app you can run in your desktop:
    http://www.2shared.com/file/2QkGQ3O6/SnapshotTaker.html


    Quote Originally Posted by GoGetIt View Post
    Hi,

    I even tried using QPixmap::grabWindow(QApplication::desktop()->winId()) to capture the contents (as shown below) but even with this I am not able to capture the flash contents.

    QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(),0,0,-1,-1);
    painter.begin(&pixmap);
    mainFrame->render(&painter);
    painter.end();
    QString file("file_Trial1.png");
    pixmap.save( file, "PNG", -1 );

    The output shows blank wherever flash content is supposed to be there.

Similar Threads

  1. Replies: 5
    Last Post: 2009-11-07, 06:10
  2. How to send % string to flash contents from flash MMI.
    By ididan in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2009-04-30, 04:15
  3. Download a web page and all its contents
    By IvanTeleca in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-10-06, 14:46
  4. How can I display Flash contents?
    By acro2488 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2008-03-21, 11:10
  5. How to turn off the flash in N73 during snapshot?
    By blisspark in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2007-09-24, 15:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×