*********
//2D Drawing quartz2d//merged image--Watermark- (void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event{ //1. Queue Groupsdispatch_group_t Group =dispatch_group_create (); dispatch_queue_t Queue= Dispatch_get_global_queue (Dispatch_queue_priority_default,0); //2. Download Picture 1__block UIImage *image1 =Nil; Dispatch_group_async (group, queue,^{Nsurl*URL1 = [Nsurl urlwithstring:@"http://g.hiphotos.baidu.com/image/pic/item/f2deb48f8c5494ee460de6182ff5e0fe99257e80.jpg"]; NSData*data1 =[NSData DATAWITHCONTENTSOFURL:URL1]; Image1=[UIImage imagewithdata:data1]; }); //3. Download Picture 2__block UIImage *image2 =Nil; Dispatch_group_async (group, queue,^{Nsurl*URL2 = [Nsurl urlwithstring:@"Http://su.bdimg.com/static/superplus/img/logo_white_ee663702.png"]; NSData*DATA2 =[NSData Datawithcontentsofurl:url2]; Image2=[UIImage Imagewithdata:data2]; }); //4. Merge pictures (ensure that all tasks within the group are executed, and then execute the block inside the Notify function)Dispatch_group_notify (group, queue, ^{ //To open a bitmap contextUigraphicsbeginimagecontextwithoptions (Image1.size, NO,0.0); //draw the 1th pictureCGFloat image1w =Image1.size.width; CGFloat image1h=Image1.size.height; [Image1 Drawinrect:cgrectmake (0,0, IMAGE1W, image1h)]; //draw the 2nd pictureCGFloat image2w = Image2.size.width *0.5; CGFloat image2h= Image2.size.height *0.5; CGFloat image2y= image1h-image2h; [Image2 Drawinrect:cgrectmake (0, image2y, image2w, image2h)]; //get the picture in contextUIImage *fullimage =Uigraphicsgetimagefromcurrentimagecontext (); //End ContextUigraphicsendimagecontext (); //5. Go back to the main thread to display the pictureDispatch_async (Dispatch_get_main_queue (), ^{self.imageView.image=Fullimage; }); });}
iOS next day multi-threaded-03 pairs of column combinations and pictures