iphone 使用Core Graphics 合成图片
2010-10-22 20:52
441 查看
//底图
UIImage *oriPic=[UIImage imageNamed:@"1.png"];
//将要画在底图上的图片
UIImage *subImage=[UIImage imageNamed:@"diy4.png"];
//创建绘图上下文
UIGraphicsBeginImageContext(oriPic.size);
CGContextRef thisctx=UIGraphicsGetCurrentContext();
//图像坐标变换
CGContextRotateCTM(thisctx, M_PI);
CGContextTranslateCTM(thisctx, -oriPic.size.width, -oriPic.size.height);
//绘制底图
CGContextDrawImage(thisctx, CGRectMake(0, 0, oriPic.size.width, oriPic.size.height), [oriPic CGImage]);
//在底图上绘制图片
CGContextDrawImage(thisctx, CGRectMake(5, 5, 30, 30), [subImage CGImage]);
//得到所绘制的图片
UIImage *newImage=UIGraphicsGetImageFromCurrentImageContext();
//关闭上下文
UIGraphicsEndImageContext();
UIImageView *imageView=[[UIImageView alloc] initWithImage:newImage];
imageView.frame=CGRectMake(160,240, 40, 40);
[self.view addSubview:imageView];
UIImage *oriPic=[UIImage imageNamed:@"1.png"];
//将要画在底图上的图片
UIImage *subImage=[UIImage imageNamed:@"diy4.png"];
//创建绘图上下文
UIGraphicsBeginImageContext(oriPic.size);
CGContextRef thisctx=UIGraphicsGetCurrentContext();
//图像坐标变换
CGContextRotateCTM(thisctx, M_PI);
CGContextTranslateCTM(thisctx, -oriPic.size.width, -oriPic.size.height);
//绘制底图
CGContextDrawImage(thisctx, CGRectMake(0, 0, oriPic.size.width, oriPic.size.height), [oriPic CGImage]);
//在底图上绘制图片
CGContextDrawImage(thisctx, CGRectMake(5, 5, 30, 30), [subImage CGImage]);
//得到所绘制的图片
UIImage *newImage=UIGraphicsGetImageFromCurrentImageContext();
//关闭上下文
UIGraphicsEndImageContext();
UIImageView *imageView=[[UIImageView alloc] initWithImage:newImage];
imageView.frame=CGRectMake(160,240, 40, 40);
[self.view addSubview:imageView];
相关文章推荐
- iphone 使用Core Graphics 剪贴图片
- iphone 使用Core Graphics 剪贴图片
- iphone-CoreGraphics切割图片
- iOS开发的2D绘制--CoreGraphics的简单使用三(画文字和图片)
- java使用BufferedImage和Graphics实现图片合成
- CoreGraphics对UIImage图片裁剪
- iOS底层绘图机制,CoreGraphics框架,和Context使用详解
- C# :实现水印与图片合成,并利用Graphics 压缩图像质量 , (委托实现listBox的动态添加提示)
- iOS底层绘图机制,CoreGraphics框架,和Context使用详解
- 使用OpenCV合成两张图片
- Nodejs下使用gm圆形裁剪并合成图片的示例
- 使用canvas来实现两张图片合成一张
- Core Graphics之(二):绘制:矩形、椭圆、圆形、文字、图片
- 使用CDC进行颜色/图片合成(透明处理)
- 使用Axure模拟高仿真iPhone交互动作(5)――图片浏览
- iOS开发的2D绘制--CoreGraphics的简单使用二(画图形)
- Swing中Graphics绘制图片,图片使用随机背景色,随机字符串
- iOS底层绘图机制,CoreGraphics框架,和Context使用详解
- iOS之CoreGraphics使用(1)
- IOS:如何使用多张图片合成GIF