UIimage to char* conversion

岁酱吖の 提交于 2019-12-11 03:55:00

问题


I am trying to convert uiimage to char array to use with libtiff.

Thanks


回答1:


Here is the easiest way that I know of to get the bytes of a UIImage:

UIImage *someImage = ...;
CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(someImage.CGImage));
const UInt8 *data = CFDataGetBytePtr(pixelData);

Data then is an array of bytes.

EDIT:

Here is how you get an char array:

const unsigned char * buffer =  CFDataGetBytePtr(pixelData);

EDIT 2:

Try casting it to char:

char * buffer = (char *)CFDataGetBytePtr(pixelData);


来源:https://stackoverflow.com/questions/9217224/uiimage-to-char-conversion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!