We are taking a UIImage and converting it to PGM as an 8-bit grayscale representation of the image.
The result is an unsigned char array of the bytes. I want to write this to a file to check what it has converted. When I do that using:
NSData *rawPGM = [NSData dataWithBytes:(const void *)somethingPGM length:strlen((char *)somethingPGM)];
NSURL *someurl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"temp.pgm"]];
[rawPGM writeToURL:someurl atomically:YES];
I get UTF-8 characters in the file, like ÚÛÜÝÝÜÛÚ××ÖÙØÚÛ
instead of a set of integers 0-255 like a normal PGM file:
0
24
57
76
91
103
How do I save the unsigned char * to a file containing the integer representations of those bytes?