I have a requirement in which i have to send an image from ios device to another device corebluetooth, other device is BLE device.
Basic needs are:
1) Image should be of size 128X160
2) 8-Bit i.e 8 bits per color
3) 3 channels
4) 24 bit per pixel
5) Image should have 61440 byes i.e (3X128X160)
To get 3 channel and 24bit per pixcel i am using below code of OpenCV as in native ios i dint find option to convert UIImage into 24bit bitmap
//uiimg is 128X160 size
cv::Mat image;
cv::Mat convertedImage;
UIImageToMat(uiimg, image);
cvtColor(image, convertedImage, CV_RGBA2BGR);
if i check number of byts and number of bits per pixel then it comes out to be as follows
img = MatToUIImage(convertedImage);
size_t bytesPerRow1 = CGImageGetBytesPerRow(img.CGImage); // It gives 3, seems like correct which is needed
size_t total = bytesPerRow1 * img.size.height; //it gives 61440, seems like correct which is need
but when i convert this UIImage into NSDate and then check [NSData bytes] then it gives me 39087bytes.
How this happens as per calculation the numbers of byts in image should be 61440 as 128X3X160.
can any one please tell why there is a difference.
Moreover the NSdata is data like
<89504e47 0d0a1a0a 0000000d 49484452 00000080 000000a0 08020000 004bf0f3 aa000000 01735247 4200aece 1ce90000 001c6944 4f540000 00020000 00000000 00500000 00280000 00500000 00500000 3d3e90d2 90340000 3d0a4944 41547801 d4bd0774 1cc7b926 3a67c3dd f7eededd ..... and so on>
But as per my requirements i have to send one byte every time. the sending data should be of type 0x41,0x72 etc.
I can get data like 0x41,0x72 using GetByte method of NSData. But in Corebluetooth to write data on device we have to send data in NSData only, So again i have to convert 0x41,0x72 to NSData.
Can i send data as NSData and is it same as sending 0x41,0x72?
Why there is difference in NSData byte count and byte count based on calculation
Any help will be highly Appreciated
Thanks