Writing a masked image to disk as a PNG file

后端 未结 2 1613
太阳男子
太阳男子 2021-02-20 01:15

Basically I\'m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I\'m using the masking code everyone seems to poi

2条回答
  •  盖世英雄少女心
    2021-02-20 01:52

    How about drawing into a new image, and then save that?

    UIGraphicsBeginImageContext(img.size);
    [img drawAtPoint:CGPointZero];
    UIImage *newImg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [UIImagePNGRepresentation(newImg) writeToFile:cachePath atomically:NO];
    

    (untested)

提交回复
热议问题