Я использую порт iPhone ImageMagick. Я пытаюсь циклично выполниться через кадры анимированного gif и превратить каждый кадр в UIImage. Я знаю, что могу init UIImage с NSData, который я могу init с константой пусто *. Таким образом, как я получаю буфер и длину изображения?
Вот код:
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);
}
Теперь у меня есть решение:
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];