2010-12-07 8 views
0

で、私は次のコードでUIImageからバイト配列を持って...バイトからUIImageを取得する。..どのようにIPhoneコード

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 red; int green; int青; int alpha;

答えて

1

以下は、コンテキストからUIImageを取得する方法です。

CGImageRef aCGImg = CGBitmapContextCreateImage(context); 
UIImage *aUIImg = [UIImage imageWithCGImage:aCGImg]; 
CGImageRelease(aCGImg); 
関連する問題