问题
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