iOS多張圖片合成

- (UIImage *)imagesSynthesis{
    UIImage * bgImg = [UIImage imageNamed:@"picsWall_bg.jpg"];
    UIImage * img1  = [UIImage imageNamed:@"1.png"];
    UIImage * img2  = [UIImage imageNamed:@"2.png"];
    UIImage * img3  = [UIImage imageNamed:@"3.png"];
    UIImage * img4  = [UIImage imageNamed:@"4.png"];
    UIImage * img5  = [UIImage imageNamed:@"5.png"];
    UIImage * img6  = [UIImage imageNamed:@"6.png"];
    
    // 得到圖片繪制上下文,指定繪制區(qū)域
    UIGraphicsBeginImageContext(CGSizeMake(640, 1136));
    
    // 背景圖
    [bgImg drawInRect:CGRectMake(0, 0, 640, 1136)];
    // img1
    [img1 drawInRect:CGRectMake(128, 136, 160, 110)];
    // img2
    [img2 drawInRect:CGRectMake(428, 136, 94, 110)];
    // img3
    [img3 drawInRect:CGRectMake(128, 378, 160, 110)];
    // img4
    [img4 drawInRect:CGRectMake(418, 380, 94, 220)];
    // img5
    [img5 drawInRect:CGRectMake(128, 618, 160, 230)];
    // img6
    [img6 drawInRect:CGRectMake(422, 728, 94, 120)];
    
    // 從當(dāng)前圖片上下文中得到image
    UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return resultingImage;
}
合成前背景圖
合成后圖片

版權(quán)聲明:出自MajorLMJ技術(shù)博客的原創(chuàng)作品 ,轉(zhuǎn)載時(shí)必須注明出處及相應(yīng)鏈接!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,174評(píng)論 25 708
  • 引言:隨著多媒體的普及,越來(lái)越多的短視頻被人們所喜愛(ài),接受,傳播,所以快速而有效的合成高質(zhì)量的視頻成為剛需。 本文...
    路飛_Luck閱讀 10,311評(píng)論 13 22
  • 摘要:近期,互聯(lián)網(wǎng)大佬均紛紛啟動(dòng)原創(chuàng)內(nèi)容保護(hù)機(jī)制,對(duì)于原創(chuàng)內(nèi)容創(chuàng)作者來(lái)說(shuō)無(wú)疑是一大利好,然而對(duì)于抄襲者來(lái)說(shuō)無(wú)疑是一...
    幻影蒙達(dá)閱讀 1,207評(píng)論 1 3
  • 安靜極了 我的世界 要怎樣 熱鬧起來(lái) 總是 不開心
    那樣_閱讀 241評(píng)論 0 0
  • 文/丫丫里里 01 韓風(fēng)最拿手的一道飯就是西紅柿雞蛋面,不同的是,他做的是燒烤味的。 那天,去韓風(fēng)家蹭飯,他一副很...
    丫丫里里閱讀 770評(píng)論 3 9

友情鏈接更多精彩內(nèi)容