Converting between multiple image formats in Objective-C

后端 未结 2 1826
傲寒
傲寒 2020-12-19 09:19

I want to be able to, being given a path to an image, convert that image into another image, but with a different format. By format I mean .png, .bmp .jpg .tiff, etc. In pse

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-19 09:33

    Exploring outward from NSImage leads you to NSBitmapImageRep, which does exactly what you want.

    Some of those iPhone questions are relevant as well, because the solution that works on both platforms (and the implementation behind the NSBitmapImageRep solution nowadays) is to use CGImageSource to read in the image and CGImageDestination to write it out.

提交回复
热议问题