Results 1 to 5 of 5

Thread: Pixmap in QGraphicsScene disappears when it is scaled above 32,767 pixels

  1. #1
    Join Date
    Oct 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Pixmap in QGraphicsScene disappears when it is scaled above 32,767 pixels

    I have a QGraphicsScene in a QGraphicsView that displays a scaled pixmap. For some reason, when the pixmap is larger than 32,767 pixels (max value of type int), it fails to show up at all or sometimes partially shows up.

    The QGraphicsView documentation for QT5 says:

    Note that although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of an integer (INT_MIN, INT_MAX).


    However, I should be able to display a pixmap larger than 32,767 pixels because I printed INT_MIN and INT_MAX and they are INT_MIN = -2147483648, INT_MAX = 2147483647 on my system (I'm running an Intel processor on Ubuntu 14.04). What could cause the pixmap to not show up when it gets larger than 32,767 pixels in one dimension? As long as it's below 32,767 pixels, the image displays properly. Is this a bug in Qt? Code below.

    Qt Code:
    1. // Transformation matrix
    2. QMatrix matrix;
    3. if(!time_vertical) {
    4. matrix.scale(1, -1);
    5. matrix.rotate(90);
    6. }
    7. matrix.scale(frequency_zoom, time_zoom);
    8. // Create pixmap
    9. pixmap.convertFromImage(*image);
    10. pixmap = pixmap.transformed(matrix);
    11. // Add pixmap to scene
    12. scene->clear();
    13. QGraphicsPixmapItem* item = scene->addPixmap(pixmap);
    14. item->setPos(0, 0); // Set pixmap origin (0, 0) in scene coordinates
    15. scene->setSceneRect(pixmap.rect());
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Pixmap in QGraphicsScene disappears when it is scaled above 32,767 pixels

    I think this is a limitation in X11.

    If I remember correctly its size arguments are 16-bit ints, so the maximum value is 32727.

    If your screen is smaller than this size then you could try scaling the image and then taking the visible part into a pixmap, or using a custom item that draws only the visible part of the scaled image or draws the visible part using painter scaling.

    If your screen is that size or larger, then you probably need a custom item that draws the scaled image in tiles.
    In that case I would also ask to attach a photo of that video wall

    Cheers,
    _

  3. #3
    Join Date
    Oct 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Pixmap in QGraphicsScene disappears when it is scaled above 32,767 pixels

    Hmm, X11? I guess I could verify by compiling and running it in Windows. That's true, I could re-draw every time the user scrolls, but that might add some lag.

    I should be able to shift the scene rectangle so it starts at -32767 instead of 0 and effectively double the largest possible size, but I haven't been able to get that to work. The QGraphics scene rectangle still starts at (0,0). Not sure why.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Pixmap in QGraphicsScene disappears when it is scaled above 32,767 pixels

    Quote Originally Posted by HereWeAre View Post
    Hmm, X11?
    You wrote Ubuntu, version from last year, so unlikely that you are using Mir as the display server.
    But of course you could be running without X11, maybe a framebuffer or EGLFS?
    Is this a desktop or an embedded system?

    Quote Originally Posted by HereWeAre View Post
    I guess I could verify by compiling and running it in Windows. That's true, I could re-draw every time the user scrolls, but that might add some lag.
    The graphics view has to redraw anyway.

    Quote Originally Posted by HereWeAre View Post
    I should be able to shift the scene rectangle so it starts at -32767 instead of 0 and effectively double the largest possible size, but I haven't been able to get that to work. The QGraphics scene rectangle still starts at (0,0). Not sure why.
    That won't help if you are on X11.
    As I wrote it uses 16 bit ints for sizes, so an X11 Pixmap (and thus a QPixmap wrapping it) can't be larger than 32767.
    Even at that size in both directions it would already consume 4GB.

    Cheers,
    _

  5. #5
    Join Date
    Oct 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Pixmap in QGraphicsScene disappears when it is scaled above 32,767 pixels

    I am definitely using X11. The Hmm was just a little surprise that the problem was there. I'll try out your suggestion. This has been very helpful, thank you!

Similar Threads

  1. Replies: 2
    Last Post: 16th February 2012, 16:26
  2. QGraphicsScene with scaled item freezes application on click
    By FlashMuller in forum Qt Programming
    Replies: 2
    Last Post: 31st January 2011, 14:51
  3. Replies: 6
    Last Post: 13th January 2010, 19:44
  4. Replies: 0
    Last Post: 6th April 2009, 02:20
  5. Inaccurate MouseEvent position over a Scaled Pixmap
    By ramstormrage in forum Newbie
    Replies: 9
    Last Post: 26th May 2008, 11:48

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.