2010-07-15 24 views
6

Estoy usando el puerto de iPhone de ImageMagick. Intento recorrer los fotogramas de un gif animado y convertir cada fotograma en un UIImage. Sé que puedo iniciar un UIImage con NSData que puedo iniciar con un const void *. Entonces, ¿cómo puedo obtener el buffer y la longitud de la imagen?Cómo obtener c buffer desde ImageMagick Image

Aquí está el código:

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); 
    } 

Respuesta

4

tengo la solución ahora:

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]; 
Cuestiones relacionadas