In below function I am trying to return UIImage
pointer which is created from NSData
- When I give option
freeWhenDone = YES
theUIImage
displayed returned from here is white image. When I give option
freeWhenDone = NO
UIImage
returned form here shows it as a black image.- When I pass
rgb_buffer
(char array) instead of[rgbData bytes]
function1 and function2 work properly. Everything is fine.
Is it something to do with ARC?
Myfunction
{
char *pu1_out_buffer = malloc(length);
int width, height, stride;
char *rgb_buffer = malloc(BUFFER_LENGTH);
pu1_out_buffer = datafromfile(FILE_PATH) // initialized with some data , not important
/* rgb NSdata created from malloced rub buffer */
NSMutableData *rgbData = [NSMutableData dataWithBytesNoCopy:rgb_buffer
length:(u4_stride * u4_height * 3)
freeWhenDone:YES];
[self function1:pu1_out_buffer
rgb_buffer:(UWORD16 *)[rgbData bytes]
…]
free(pu1_out_buffer);
UIImage *outUIImage = [self function2:rgbData
width:u4_width
height:u4_height
stride:u4_stride];
return outUIImage;
}