Getting pixel data from UIImageView — works on simulator, not device

后端 未结 3 395
猫巷女王i
猫巷女王i 2020-12-18 10:24

Based on the responses to a previous question, I\'ve created a category on UIImageView for extracting pixel data. This works fine in the simulator, but not when deployed to

3条回答
  •  悲哀的现实
    2020-12-18 10:37

    You could try the following alternative approach:

    • create a CGBitmapContext
    • draw the image into the context
    • call CGBitmapContextGetData on the context to get the underlying data
    • work out your offset into the raw data (based on how you created the bitmap context)
    • extract the value

    This approach works for me on the simulator and device.

提交回复
热议问题