Objective-C: Comparing an image against another image that has been previously saved

前端 未结 2 2007
清酒与你
清酒与你 2020-12-20 16:00

I have a question about comparing UIImages in Objective-C when one image has already been through a save and load process using the NSSearchPathForDirectoriesInDomains metho

2条回答
  •  [愿得一人]
    2020-12-20 16:10

    Your images certainly have different addresses since one is loaded from your application bundle and one is loaded from the documents directory. The [UIImage imageNamed:] function only returns images from the application bundle.

    If you really want to compare the images by contents, check out this SO question. In the first answer, a hash value s computed for an image. In your code, you could compare the hash values of the two images you have. The second answer compares the images directly, in case hashes make you nervous.

    I recommend going a different route and having your application track which image is loaded outside of the image itself.

提交回复
热议问题