2010-07-15 11 views
6

Sto utilizzando la porta iPhone di ImageMagick. Sto cercando di scorrere i fotogrammi di una gif animata e trasformare ogni fotogramma in un UIImage. So che posso avviare un UIImage con NSData che posso avviare con un const *. Quindi, come ottenere il buffer e la lunghezza dell'immagine?Come ottenere il buffer c da ImageMagick Image

Ecco il codice:

MagickReadImage(wand, filename); 

     while(MagickHasNextImage(wand)) { 
      Image *myImage = GetImageFromMagickWand(wand); 
      //HELP ME PLEASE 
      const void *myBuff =myImage->blob; //guessing this is the right way to get the buffer? 
      int myLength = ????? //no idea how to get the length 
      NSData *myData = [[NSData alloc] initWithBytes:myBuff length:myLength]; 
      UIImage myImage = [[UIImage alloc] initWithData:myData]]; 
      MagickNextImage(wand); 
    } 

risposta

4

ho la soluzione ora:

size_t my_size; 
    unsigned char * my_image = MagickGetImageBlob(wand, &my_size); 
    NSData * data = [[NSData alloc] initWithBytes:my_image length:my_size]; 
    free(my_image); 

    UIImage * image = [[UIImage alloc] initWithData:data];