Here is what I'm doing to calculate an Image checksum :
Qt Code:
{ quint16 checksum = qChecksum((char *) (image.bits()), image.numBytes()); return checksum; }To copy to clipboard, switch view to plain text mode
Is it the good approach ?
Here is what I'm doing to calculate an Image checksum :
Qt Code:
{ quint16 checksum = qChecksum((char *) (image.bits()), image.numBytes()); return checksum; }To copy to clipboard, switch view to plain text mode
Is it the good approach ?
What do you need that checksum for?
To check wether a Pixmap is already in my cache or not.
How many pixmaps are you going to operate on? Also take a look at QPixmapCache.
I just want to validate if my checksum calculation is good.
And yes I'm using pixmap cache, in my case pixmap's path is not enough to define a pixmap.
bunjee (23rd May 2008)
Unfortunately I get some glitches using that approach.
Since I'm using a huge number of pixmap, sometimes it picks the same one.
How can I refine this ?
How about a combination of file path and creation date?
Not good in my case I want to rely on QImage's data and that's all.
I've seen there is a 32bit checksum in Zlib, has anyone ever used that ? I don't want to add one dependency just for a checksum.
Well I'm developping an instant messenging app.
Basically this is all the contact avatars.
BUT cached and displayed in various size, so I can have the same base pixmap but resized AND cached.
I think I might use a combination of checksum and pixmap size to match them.
What is the maximum size of such pixmap?
Is the checksum valid only during a single session or you want to keep it after user closes the application? Is it important for you that two exactly the same pixmaps that come from two different sources have the same checksum?
No maximum size.What is the maximum size of such pixmap?
Valid during a given session.Is the checksum valid only during a single session or you want to keep it after user closes the application?
Yes it is, it speeds up the display that I don't regenerate the pixmap.Is it important for you that two exactly the same pixmaps that come from two different sources have the same checksum?
Bookmarks