I have an unsigned char* data with the following values, as seen while debugging in xcode,
\\xc1\\xc1\\xc1\\xc1\\xc1\\xc1\\xc1\\xc0\\x84\\x03\\x03\\x02\\x03\\x02\\x03\\x03\\x03\\x02\\x02\\x03\\x02\\x03\\x02\\x02\\x03\\x02\\x02\\x02\\x02\\x03\\x03\\x03\\x03\\x03\\x02\\x02\\x03\\x03\\x03\\x02\\x02\\x03\\x02\\x02\\x02\\x02\\x03\\x03\\x03\\x02\\x02\\x02\\x02\\x03\\x02\\x03\\x02\\x03\\x02\\x03\\x02\\x03\\x02\\x03\\x02\\x02\\x02\\x03\\x03\\x03\\x03\\x03\\x02\\x03\\x02\\x03\\x02\\x03\\x03\\x02\\x02\\x03\\x03\\x03\\x02\\x02\\x02\\x02\\x02\\x03\\x02\\x02\\x03\\x02\\x03\\x02\\x02\\x03\\x03\\x03
This is the data array for a qr code.
Symbol data is represented as an array contains width*width uchars. Each uchar represents a module (dot). If the less significant bit of the uchar is 1, the corresponding module is black.
In the above case the width is 177 .
I have tried various combination in CGBitmapContextCreate, but always seem to get NULL.
Please advise.
Your help will be much appreciated.
I have successfully used :
CGImageRef refImage = [myUIImage CGImage];
CGContextRef ctx;
int w = CGImageGetWidth(refImage);
int h = CGImageGetHeight(refImage);
int bytesPerRow = CGImageGetBytesPerRow(refImage);
ctx = CGBitmapContextCreate(rawData,
w,
h,
8,
bytesPerRow,
CGImageGetColorSpace( refImage ),
kCGImageAlphaPremultipliedLast );
// Fill in rawData, which is the unsigned char pixel array
refImage = CGBitmapContextCreateImage (ctx);
UIImage* myUIImage2 = [UIImage imageWithCGImage:refImage];
CGContextRelease(ctx);
CGImageRelease(refImage);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.