March 10, 2011

naughtykid naughtykid
Lab Rat
1 posts

QImageReader::SetClipRect limitation on size(Large Image)

 

The limitation on rect varies on systems, which I don’t know why.
I want to display a very large image 20000 × 30000 of image on graphicView.
anyone encounter the limitation on this?

  1. SetClipRect
  2. {
  3. System:
  4. Dell Vostro 1510
  5. Intel Core 2 Duo T8100 2.09 GHz
  6. 3 GB of RAM
  7. Window XP 32 bit service pack 3
  8. QImageReader::setClipRect() support up to 13824 x 13824(vice versa) only
  9.  
  10. System:
  11. AMD QuadCore phenom 3 GHz
  12. 8 GB of RAM
  13. Window XP 64 bit
  14. QImageReader::setClipRect() support up to 14234 x 14235(vice versa) only
  15.  
  16. System:
  17. Dell Vostro 1400
  18. Intel Core 2 Duo T7250 2.0 GHz
  19. 2 GB of RAM
  20. Window XP 32 bit service pack 3
  21. QImageReader::setClipRect() support up to 15000 x 15894(vice versa) only
  22.  
  23. System:
  24. Dell Vostro 3700
  25. Intel Core i5 2.27 GHz
  26. 4 GB of Ram
  27. Window 7 64 bit
  28. QImageReader::setClipRect() support up to 18880 x 18881(vice versa) only
  29. }

EDIT: please use code highlighting by @-tags. thanks. Gerolf

3 replies

March 15, 2011

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1274 posts

there are known issues of loading such large images .. you might want to break it to chunks and load and stitch them while displaying

March 15, 2011

peppe peppe
Ant Farmer
1005 posts
naughtykid wrote:
The limitation on rect varies on systems, which I don’t know why. I want to display a very large image 20000 × 30000 of image on graphicView. anyone encounter the limitation on this?

Are you aware that a 20k x 30k / 32bpp image requires 2*3*4E8 byte = 2,4 GByte of contiguous memory for being loaded? Yes, QImage isn’t that smart. Split the image in chunks and load them on demand or so.

 Signature 

Software Engineer
KDAB (UK) Ltd., a KDAB Group company

March 16, 2011

naughtykid naughtykid
Lab Rat
1 posts

Thank you for the reply.

Here’s what I did:

  1. {
  2. QImageReader reader1(file);
  3. reader1.setClipRect(QRect(halfWidth, 0, halfWidth, halfHeight));
  4. QPixmap img01 = QPixmap::fromImage(reader1.read());
  5. QGraphicsItem* itemHolder = reinterpret_cast<QGraphicsItem*>(_scene.addPixmap(img01));
  6. }
  7.  
  8. {
  9. QImageReader reader2(file);
  10. reader2.setClipRect(QRect(0, 0, halfWidth, halfHeight));
  11. QPixmap img02 = QPixmap::fromImage(reader2.read());
  12. QGraphicsItem* itemHolder = reinterpret_cast<QGraphicsItem*>(_scene.addPixmap(img02));
  13. }
  14.  
  15. {
  16. QImageReader reader3(file);
  17. reader3.setClipRect(QRect(halfWidth, halfHeight, halfWidth, halfHeight));
  18. QPixmap img03 = QPixmap::fromImage(reader3.read());
  19. QGraphicsItem* itemHolder = reinterpret_cast<QGraphicsItem*>(_scene.addPixmap(img03));
  20. }
  21.  
  22. {
  23. QImageReader reader4(file);
  24. reader4.setClipRect(QRect(0, halfHeight, halfWidth, halfHeight));
  25. QPixmap img04 = QPixmap::fromImage(reader4.read());
  26. QGraphicsItem* itemHolder = reinterpret_cast<QGraphicsItem*>(_scene.addPixmap(img04));
  27. }
  28.  
  29. ui.graphicsView->show();

Just to confirm is this the correct way to split the image in chunks. I’m still pretty new to Qt :)

 
  ‹‹ Qt 4.7.2 and VS2008 qglobal.h error      [Solved] Get coordinates from mousPressEvent ››

You must log in to post a reply. Not a member yet? Register here!