Re: Comparing two images
Re: Comparing two images
- Subject: Re: Comparing two images
- From: Alastair Houghton <email@hidden>
- Date: Fri, 28 Nov 2003 10:47:48 +0000
On 28 Nov 2003, at 10:25, Lorenzo wrote:
>
When I met the first different byte I close the routine and say: they
>
are
>
not equal. Correct?
Not necessarily. It is possible to have the same image saved in the
same format but in files that differ(!) This is true for a variety of
reasons, including:
* Padding or "reserved" fields in some file formats, the contents of
which are not always defined (so some of them might not be explicitly
initialised by software that writes the files).
* Different choices re. compression. Even with the same compression
method (and some formats support multiple compression methods), it's
possible in some file formats to specify parameters for the compression
technique, in which case different software is free to choose different
parameters.
* Ordering of elements. In formats like TIFF and PNG, the file
consists of a sequence of tagged records; these records won't
necessarily occur in the same order, for example because different
programs write them out in a different order.
* Fields that inherently differ. Save count, or timestamp fields, for
example.
Are you trying to compare the *image*, or the file? Can you guarantee
that the same image will be in an identical file (for your
application)? (Hint: you'll need to check the specs for the image
format you're using; even something as simple as a timestamp field
could mess-up this assumption.)
>
I have some Carbon code somewhere that opens files and read them chunk
>
by
>
chunk using FSpOpenRF, GetEOF, SetFPos, FSRead. Do you think it can
>
still
>
work well on MacOS X?
Probably, but see below.
>
I know they cannot manage data or resource forks > 2GB. Or, how to do
>
that with Cocoa? With NSFileWrapper?
No, no, *no*! NSFileWrapper isn't there for you to use for loading
files. It's there so you can embed a file in an NSTextView.
NSFileHandle is the Cocoa way to access files.
You could also consider the BSD functions, which will work just fine
for this application. (BTW, if you want to open a resource fork using
Cocoa or BSD APIs, you can just open "<filename>/..namedfork/rsrc".)
Kind regards,
Alastair.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.