×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    5

    image rendering problem with webkit

    Hello, I hope someone can help me with this problem:

    I wanted to try this out: http://labs.trolltech.com/blogs/2008...vg-rasterizer/
    but when I use it on a svg I created I only get about 200x200 of the about 4000x8000 pixels rendered. The rest is transparent.

    I posted my version here (.h, .cpp, .svg): http://pastebin.ca/1759530

    I use Qt4.6 and Webkit from SVN (v532.4) - but the built-in webkit displays the same behaviour.
    Another thing: when I opened the svg in several webkit-powered browsers, as well as firefox and inkscape it displays just fine.

    Thanks!

  2. #2
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    286

    Re: image rendering problem with webkit

    So you ran this on s60 (emu/HW) ?

    I can see an issue with memory size required to render your image.
    4000x8000x32b == 128MB ! of RAW data and cannot be loaded on device with 30-50MB free RAM without scaling.

    The resulting render operation goes through software rasterizer and has to be blitted on bitmap at some point.. which is where your end up consuming the memory even if the original image was vector based.

    You can try playing with EPOCHEAPSIZE and setting the emulator RAM size (epoc32/data/epoc.ini) to see if you get additional scanlines rendered.

    -Janne

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    5

    Re: image rendering problem with webkit

    Actually, I ran that on my Ubuntu 9.10 machine with 2GB of ram. The program spends some quality time qith 99% CPU usage and occupying around 500MB of ram, then finishes, with the said output.

    It works perfectly if I scale up small (250x250px) SVGs with it up to 2000x2000px.

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: image rendering problem with webkit

    Did you try to fix bugs in your application?

    Code:
    main.cpp: In function 'int main(int, char**)':
    main.cpp:66: warning: 'h' may be used uninitialized in this function
    main.cpp:66: warning: 'w' may be used uninitialized in this function

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: image rendering problem with webkit

    Code:
    #include <QtGui>
    #include <QSvgWidget>
    #include <QSvgRenderer>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        QSvgWidget svg("test.svg");
    
        QSize originalSize = svg.renderer()->defaultSize();
        QSize targetSize = originalSize / 40;
    
        QImage image(targetSize, QImage::Format_ARGB32_Premultiplied);
    
        qDebug() << originalSize << targetSize;
    
        QPainter painter(&image);
    
        svg.renderer()->render(&painter);
    
        if(image.save("test.png", 0, 90))
            qDebug() << "should be ok";
        else
            qDebug() << "something bad happened";
    }

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    5

    Re: image rendering problem with webkit

    The reason that I'm using WebKit is because QtSVG only supports SVG Tiny 1.2, but I need full SVG support for my purposes (I can't tell other people they have to change their SVGs because my app can't render them correctly otherwise...)
    But thanks for taking a look. The warnings are fixed by setting w and h = 0 where they are declared.

    As far as I understand it, WebKit uses it's own (default) painter... maybe it's unhappy with QImage as painter.
    I'll try something in that direction when I'm home.

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: image rendering problem with webkit

    Quote Originally Posted by Flo1240 View Post
    As far as I understand it, WebKit uses it's own (default) painter... maybe it's unhappy with QImage as painter.
    I'll try something in that direction when I'm home.
    Try this code:
    Code:
    page()->setViewportSize(page()->mainFrame()->contentsSize());

  8. #8
    Registered User
    Join Date
    Jul 2009
    Posts
    5

    Re: image rendering problem with webkit

    WOW thank you! That did it.

    I'll run some more tests, but it looks like that was it.

    Tanks again!

  9. #9
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: image rendering problem with webkit

    BTW, you don't need QWebFrame::evaluateJavaScript() because you have QWebFrame::contentsSize().

Similar Threads

  1. Problem setting image on button
    By marstelecom in forum Mobile Java Games
    Replies: 0
    Last Post: 2009-08-12, 06:22
  2. Modules required :)
    By neil.young in forum Symbian
    Replies: 20
    Last Post: 2009-06-07, 11:35
  3. J2me polish background image problem
    By poojs in forum Feedback - Nokia Developer Services & Infrastructure
    Replies: 1
    Last Post: 2009-05-25, 07:08
  4. Image or Sprite, thats the problem
    By Tiger79 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-10-02, 08:59
  5. Resizing image problem
    By Mr.Developer in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2007-03-22, 23:22

Posting Permissions

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