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

后端 未结 6 2027
说谎
说谎 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:22

    Something along these lines:

    1. Create a 1 px square CGContext
    2. Draw the image so it fills the context
    3. Test the one pixel of the context to see if it contains any data. If it's completely transparent, consider the picture blank

    Others may be able to add more details to this answer.

提交回复
热议问题