如何在IPhone代码中从字节…获取UIImage

如何在IPhone代码中从字节…获取UIImage,iphone,uiimage,bytearray,Iphone,Uiimage,Bytearray,我通过下一个代码从UIImage获得了字节数组 context = CGBitmapContextCreate( (void*) pixelData, inImage.size.width, inImage.size.height, RGBA_8_BIT,

我通过下一个代码从UIImage获得了字节数组

context = CGBitmapContextCreate(    (void*) pixelData,
                                inImage.size.width,
                                inImage.size.height,
                                RGBA_8_BIT,
                                bytesPerRow,
                                colorSpace,
                                kCGImageAlphaPremultipliedLast );

//  Make sure we have our context   
if ( ! context )    
{
    free( pixelData );
    NSLog( @"Context not created!" );
}


//  Draw the image to the bitmap context.   
//  The memory allocated for the context for rendering will then contain the raw image pixelData in the specified color space.
CGRect rect = {     { 0 , 0 }, { inImage.size.width, inImage.size.height }        };
CGContextDrawImage( context, rect, inImage.CGImage );

// Now we can get a pointer to the image pixelData associated with the bitmap context.
pixelData = (RGBAPixel*) CGBitmapContextGetData( context );
现在。。我想要“像素数据”中的UIImage。。。救命

RGBAPixel是一个结构。。。
-->红色;绿色;蓝色;int-alpha

以下是从上下文获取UIImage的方法

CGImageRef aCGImg = CGBitmapContextCreateImage(context);
UIImage *aUIImg = [UIImage imageWithCGImage:aCGImg];
CGImageRelease(aCGImg);