How to check if a uiimage is blank? (empty, transparent)

后端 未结 6 2084
说谎
说谎 2020-12-31 23:07

which is the best way to check whether a UIImage is blank?
I have this painting editor which returns a UIImage; I don\'t want to save this imag

6条回答
  •  余生分开走
    2020-12-31 23:33

    One idea would be to call UIImagePNGRepresentation to get an NSData object then compare it with a pre-defined 'empty' version - ie: call:

    - (BOOL)isEqualToData:(NSData *)otherData
    

    to test?

    Not tried this on large data; might want to check performance, if your image data is quite large, otherwise if it's small it is probably just like calling memcmp() in C.

提交回复
热议问题