2010-12-07 51 views
0

Je suis tableau d'octets de UIImage par le code suivant ..Comment obtenir UIImage de Byte ... au Code 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); 

maintenant .. Je veux UIImage de "pixelData" ... .. aider

RGBAPixel est une struct ... -> int rouge; int vert; int bleu; int alpha;

Répondre

1

Ce qui suit est la façon dont je reçois un UIImage de contexte.

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