Iphone “创建瓷砖”;“在飞行中”;

Iphone “创建瓷砖”;“在飞行中”;,iphone,ios,core-graphics,tiles,Iphone,Ios,Core Graphics,Tiles,有没有什么解决方案可以让你在“飞行中”创造出高性能的照片呢?! 我已经看过了,但效果不太好 其目的是创建一个像Apple photoapp一样的快速照片查看器。因此,我需要根据从应用程序创建或下载到应用程序的照片创建平铺。您最好的选择可能是使用核心图形和图像I/O CGImageRef image = ...; // the big image to slice, don't draw with this image or it will decompress and might chew up

有没有什么解决方案可以让你在“飞行中”创造出高性能的照片呢?! 我已经看过了,但效果不太好


其目的是创建一个像Apple photoapp一样的快速照片查看器。因此,我需要根据从应用程序创建或下载到应用程序的照片创建平铺。

您最好的选择可能是使用核心图形和图像I/O

CGImageRef image = ...; // the big image to slice, don't draw with this image or it will decompress and might chew up all your memory
NSURL *url = ...; // the url for this slice
NSString *uti = @"public.jpeg"; // just an example, you should get the correct one for your images
CGSize sliceSize = 256.0; // for example
size_t column = 0;
size_t row = 0; // row and column should vary across your image
CGFloat colWidth = 256.0; // should account for the final column not being 256
CGFloat rowWidth = 256.0; // should account for the final row not being 256
CGRect sliceRect = CGRectMake(floor(column * sliceSize), floor(row * sliceSize),
                                    floor(colWidth), floor(rowHeight));
CGImageRef slicedImage = CGImageCreateWithImageInRect(image, sliceRect);
if(NULL == slicedImage) {
    NSLog(@"hosed image");
}
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((CFURLRef)url, (CFStringRef)uti, 1, NULL);
CGImageDestinationAddImage(destination, slicedImage, NULL);
if(!CGImageDestinationFinalize(destination)) {
    NSLog(@"hosed write of %@", [url path]);
}
CFRelease(destination);
CGImageRelease(slicedImage);
作为警告,这是根据记忆拼凑而成的,可能是错误的。请看一下文件,看看我把事情搞砸了

以下是关于这项技术的文档


不幸的是,它没有那么出色。我想在可接受的时间内“即时”创建瓷砖是不可能的。但是谢谢你的回答!