2010-07-15 10 views
6

मैं ImageMagick का आईफ़ोन पोर्ट उपयोग कर रहा हूं। मैं एनिमेटेड gif के फ्रेम के माध्यम से लूप करने की कोशिश कर रहा हूं और प्रत्येक फ्रेम को UIImage में बदल सकता हूं। मुझे पता है कि मैं एनआईडीएटा के साथ एक यूआईएममेज में प्रवेश कर सकता हूं जिसे मैं एक कॉन्स शून्य * के साथ जोड़ सकता हूं। तो मैं छवि के बफर और लंबाई कैसे प्राप्त करूं?ImageMagick छवि से सी बफर कैसे प्राप्त करें

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

उत्तर

4

मैं अब समाधान है:

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

कोड यह

संबंधित मुद्दे