2012-03-13 75 views
1

我已經捕捉UIView的內容。有很多方法來捕捉內容。
問題是,,如果視圖的大小變得過大,應用程序崩潰,因爲它需要的內存數量巨大。
所以是否有可能合併的原始圖像數據(執行逐字節操作)在單個文件中,使圖像從??組合多個圖像以獲得單個圖像

回答

0
`enter code here`Merging two images to create one single image file 

Suppose we have two images with name file1.png and file2.png The code below merges two images. 

@implementation LandscapeImage 
- (void) createLandscapeImages 
{ 
    CGSize offScreenSize = CGSizeMake(2048, 1380); 
    UIGraphicsBeginImageContext(offScreenSize); 
//Fetch First image and draw in rect 
    UIImage* imageLeft = [UIImage imageNamed:@"file1.png"]; 
    CGRect rect = CGRectMake(0, 0, 1024, 1380); 
    [imageLeft drawInRect:rect]; 
    [imageLeft release]; 

//Fetch second image and draw in rect  
    UIImage* imageRight = [UIImage imageNamed:@"file2.jpg"]; 
    rect.origin.x += 1024; 
    [imageRight drawInRect:rect];  
    [imageRight release]; 

    UIImage* imagez = UIGraphicsGetImageFromCurrentImageContext();// it will returns an image based on the contents of the current bitmap-based graphics context. 
    if (imageLeft && imageRight) 
    { 
    //Write code for save imagez in local cache 
    } 
    UIGraphicsEndImageContext(); 
} 
@end 
+1

這是同一次捕獲整個看法。它帶來的一切記憶和大規模的看法,內存變成多少來處理。 – 2012-03-13 08:00:15