在下面的函数中,我试图返回UIImage
从创建的指针NSData
- 当我给出选项时,从这里返回
freeWhenDone = YES
的显示是白色图像。UIImage
当我给出选项时
freeWhenDone = NO
UIImage
此处返回的表格将其显示为黑色图像。- 当我通过
rgb_buffer
(char array) 而不是[rgbData bytes]
function1 和 function2 时正常工作。一切都很好。
跟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;
}