Results 1 to 7 of 7

Thread: QPixmap not displayed on windows / no proble on Linx -> Qt Bug or not?

  1. #1
    Join Date
    Apr 2006
    Posts
    3
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default QPixmap not displayed on windows / no problem on Linux -> Qt Bug or not?

    Hi,
    I am displaying images in a scrollview. I also have scaling functionality that works without problems on linux. When I do the same on windows the image won't be displayed when the size exceeds approximately 3000x30000 pixels. Is there a problem with Qt or am I doing something wrong?
    Qt Code:
    1. //
    2. //this code is inside a class that subclasses QScrollView
    3. //
    4. QVBox *box = new QVBox(viewport());
    5. addChild(box);
    6.  
    7. ...
    8.  
    9. imgLabel_ = new QLabel(box);
    10. isOk = pixMapScaled_.convertFromImage(
    11. image_.scale(static_cast<int>(image_.width()*scaleFactor_),
    12. static_cast<int>(image_.height()*scaleFactor_)),
    13. conversion_flags_);
    14.  
    15. if (isOk)
    16. imgLabel_->setPixmap(pixMapScaled_);
    17. else
    18. logger_.error("Could not convert image.");
    To copy to clipboard, switch view to plain text mode 

    The scaling and conversion seems to happen without any errors. The image is just not displayed on windows when it gets bigger than 3000x3000 pixels. When scaling out again it will be displayed again.
    Thanks, for any help,
    Guido
    Last edited by ali99; 5th April 2006 at 13:05.

  2. #2
    Join Date
    Jan 2006
    Posts
    109
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QPixmap not displayed on windows / no proble on Linx -> Qt Bug or not?

    Can you provide a minimal compilable example that reproduces the problem?

    My guess is that you're trying to create very large pixmaps (larger than the screen) which isn't needed and may fail on some systems. It's hard to help more without details.

    A QImage an be any size you want (provided there's enough system memory) but a QPixmap is specifically used to display, so it doesn't make sense to have a pixmap larger than the screen typically.

  3. #3
    Join Date
    Apr 2006
    Posts
    3
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap not displayed on windows / no proble on Linx -> Qt Bug or not?

    why should it not make sense to have a pixmap that is bigger than the screen? When you scale a high resolution image in order to zoom into the image it will become very quick bigger than the screen. In my case (1280x1024) it was working until 2700x2700 pixels. When I reached 3000x3000 it stopped displaying it. My application needs to be able to zoom into images. And it all works on linux without problems.
    Thanks so much for your help,
    Guido

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPixmap not displayed on windows / no proble on Linx -> Qt Bug or not?

    The proper question is -- does your application need to use QPixmap for this? And a second question -- does the image need to be that big to be shown zoomed?

  5. #5
    Join Date
    Apr 2006
    Posts
    3
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap not displayed on windows / no proble on Linx -> Qt Bug or not?

    To use QPixmap is the only way I know to do what I want to do. That is showing an image in a QScrollView. When the image is zoomed in you can scroll that image to any position wanted. I am not an expert with using Qt, rather an intermediate. And doing that QImage->QPixmap->QLabel - "trick" looked strange to me but that is what I was told to do in order to get the wanted results.
    Guido

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPixmap not displayed on windows / no proble on Linx -> Qt Bug or not?

    How about using QPainter::drawImage() instead? And QPainter::scale() for zooming?

    If you have a 300x300 pixel image which occupies about 100kB of memory and you zoom it 4 times (making it 1200x1200) you'll use 1.5MB of memory... with 3000x3000 it'll be 9MB, etc. If you use QPainter::scale and QPainter::drawImage, you'll be at 100kB memory usage all the time.

  7. #7
    Join Date
    Jan 2006
    Posts
    109
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QPixmap not displayed on windows / no proble on Linx -> Qt Bug or not?

    A QImage lives in your system's main memory and can therefore be quite large.

    A QPixmap is handled by the graphics subsystem of your computer and there are limitations on the size of pixmaps that can be handled. This is not a Qt issue.

    What you want is to load an image into a QImage (or some other custom specialized structure) in main memory. Then you extract/transform/zoom whatever part of the QImage you need to display, transforming it into a QPixmap and always trying to keep the pixmap a reasonable size. Again, this limitation is not related to Qt.

    Now, instead of programming all that by yourself, you could reuse code from existing Qt or KDE high-level widgets that display images and can handle rotations, zooming, shearing, etc.

    I don't have links to such programs right now, except maybe GRASS/Qt, but you'll probably be interested in A Zoomable Picture Viewer.

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.