If I do the math, a 2000 x 2000 pixel image is 4 million pixels. If each pixel is a 32-bit RGBA value, this is 16 MB per image, more than the size of the cache for just one image. They are obviously compressed to a smaller size on disk.
If I do the math, a 2000 x 2000 pixel image is 4 million pixels. If each pixel is a 32-bit RGBA value, this is 16 MB per image, more than the size of the cache for just one image. They are obviously compressed to a smaller size on disk.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
I thought you might be correct d_stranz, so I dissected the image and determined that it only has a depth of 8.
So, in the Qt 5.9 documentation under the Qt 5.8 - Qt GUI - C++ Classes – QpixmapCache description, it states in the ‘Detailed Description’ section, that “The initial cache limit is 10240 KB (10 MB); you can change this by calling setCacheLimit() with the required value. A pixmap takes roughly (width * height * depth)/8 bytes of memory.â€
If an image is 2000 pixels by 2000 pixels and the depth is 8 pixels, I get 4,000,000 divided by a depth of 8 bits per pixel = 500,000. Divide that by 8 bytes of memory (or should I divide by 64 bits of memory) I get 62,500. Therefore, two images would require a cache size of 125,000 bits, bytes or kilobytes?????
Based on the above documentation, I am assuming that (width (in pixels) * height (in pixels) * depth (bits per pixel)) / bytes of memory returns a value that is in bytes. However it could just as easily be bits, bytes or KB. If someone could provide clarification on this, it would be highly appreciated.
Try the math again: (width * height * depth) / 8 = (2000 * 2000 * 8)/8 = 4 million bytes. "depth" is always in bits / pixel (not pixels), and the final division by 8 converts bits to 8-bit bytes.
After you load the image, what does QPixmap::depth() say?
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Corny (23rd May 2017)
Yeah you're right, thanks. I divided instead of multiplying.
As to the depth of the pixmap, it fails when loading so I can never get to the point to use the QPixmap::depth() function. The only data that the Locals and Expressions window displays for the image information is the following; width: 2000, height: 2000, nbytes: 16000000, format: 456327200, data: 0x6bcce780. Would I be wrong to assume that nbytes is the number of bytes? In any event, not sure that any of these values represent the depth.
But, thanks to your assistance, I've eliminated the SIGSEGV issue (at least for now) and now receive "can't find linker symbol for virtual table for `QPixmap' value" in the application output. I'm going to do some searching to see I if can figure this new one out. I'm sure I'll post again if I can't. So d_stranz, thank you very much for your support to date.
Bookmarks