GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Apr 23, 2014 5:48 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Compare two Pixbufs
PostPosted: Wed Sep 05, 2012 2:50 pm 

Joined: Wed Sep 05, 2012 2:42 pm
Posts: 1
Im trying to write a simple clipboard-manager.
So now i check the clipboard regularly to see if there is something new.
But for this i need to compare the Pixbufs i already have in my list with the Glib.Value containing a Pixbuf from Clipboard (to see if the image from clipboard is already in my list).
Is there an easy way to do this?
If i copy a file i also get location and filename in the clipboard so i can easily check. But copying an image there seems to be no metadata at all i could compare =/

any tip appreciated

 Post subject: Re: Compare two Pixbufs
PostPosted: Wed Sep 05, 2012 4:57 pm 
Familiar Face

Joined: Wed Sep 05, 2012 2:02 am
Posts: 7
Hello Sr EvilTwin
I'm not sure if I get your point of view about this. From what I understand, you like to compare if you have some repeated data inside clipboard, and if yes, ignore that data or perform some action.
Data in this context can be anything, can be a song file, an image file, a text, and can be what I do not have think about.
The solution is to look to data contents of the clipboard with raw eyes, just a byte sequence.
Its inviable if you have bigger files in clipboard, and compare each one against each other can spend some time.
Well, if you take a 'hash' of that data, things can be more easy. So, the 'hash' algorithm (like a mathematical formula) read all the data of specific files and return to you a number (hash). You need store this number for future reference. So, you copy the same file again on clipboard, the algorithm take action, and return to you a number. By comparing hashes, you can know if the file is the same or not.
So, to each file in memory you will have a hash as reference. The hash results generally have 16 bytes longer (spend less time comparing 16 bytes instead of all the file again), can have more or less bytes depending of your hash algorithm.
Linux have a md5sum tool.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group