NSImage to Base64

后端 未结 6 861
春和景丽
春和景丽 2021-01-18 06:51

I need to create a base64 string representation of an NSImage cocoa object. What\'s the best way of handling this, apple documentation seems to be a little short on the subj

6条回答
  •  花落未央
    2021-01-18 07:40

    Apple doesn't provide any particular help here, so you do have to tackle the complexity on your own, one way or another.

    Fortunately, there are some resources available to make this easier. The first approach is to literally do the encoding and decoding yourself. Google Toolbox for Mac has a good example of this approach and you might be able to just use this source file as-is:

    http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMBase64.m

    If you're building only for the Mac, where the OpenSSH libraries are available, then you could take advantage of some functions in those libraries to do the encoding and decoding:

    http://www.dribin.org/dave/blog/archives/2006/03/12/base64_cocoa/

提交回复
热议问题