合成图片的两种方法
2012-08-24 18:43
211 查看
- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame= CGRectMake(520, 280, 320, 480);
CGImageRef small;
small= CGImageCreateWithImageInRect([[UIImage imageNamed:@"3.png"] CGImage],frame);
UIImageView *test=[[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:small]];
[self.view addSubview:test];
[test release];
}
合成图片的两种方法,思路都是一样的
// Image+Image ICON
- (UIImage *)addImage:(UIImageView *)image1 toImage:(UIImageView *)image2 {
CGSize size= CGSizeMake( image1.frame.size.width,image1.frame.size.height);
UIGraphicsBeginImageContext(size);
// Draw image1
[image2.image drawInRect:CGRectMake(6, 6,
image2.frame.size.width, image2.frame.size.height)];
// Draw image2
[image1.image drawInRect:CGRectMake(0, 0,
image1.frame.size.width, image1.frame.size.height)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}
- (UIImage *)addImageview:(UIImage *)image1 toImage:(UIImage *)image2 {
CGSize size= CGSizeMake( image1.size.width,image1.size.height);
UIGraphicsBeginImageContext(size);
// Draw image1
[image2 drawInRect:CGRectMake(4.5, 6, 77, 77)];
// Draw image2
[image1 drawInRect:CGRectMake(0, 0, image1.size.width,
image1.size.height)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}
[super viewDidLoad];
CGRect frame= CGRectMake(520, 280, 320, 480);
CGImageRef small;
small= CGImageCreateWithImageInRect([[UIImage imageNamed:@"3.png"] CGImage],frame);
UIImageView *test=[[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:small]];
[self.view addSubview:test];
[test release];
}
合成图片的两种方法,思路都是一样的
// Image+Image ICON
- (UIImage *)addImage:(UIImageView *)image1 toImage:(UIImageView *)image2 {
CGSize size= CGSizeMake( image1.frame.size.width,image1.frame.size.height);
UIGraphicsBeginImageContext(size);
// Draw image1
[image2.image drawInRect:CGRectMake(6, 6,
image2.frame.size.width, image2.frame.size.height)];
// Draw image2
[image1.image drawInRect:CGRectMake(0, 0,
image1.frame.size.width, image1.frame.size.height)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}
- (UIImage *)addImageview:(UIImage *)image1 toImage:(UIImage *)image2 {
CGSize size= CGSizeMake( image1.size.width,image1.size.height);
UIGraphicsBeginImageContext(size);
// Draw image1
[image2 drawInRect:CGRectMake(4.5, 6, 77, 77)];
// Draw image2
[image1 drawInRect:CGRectMake(0, 0, image1.size.width,
image1.size.height)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}
相关文章推荐
- 合成图片的两种方法,思路都是一样的
- 合成图片的两种方法,思路都是一样的
- PHP基于imagick扩展实现合成图片的两种方法【附imagick扩展下载】
- Android:将数字画在图片上合成一张图的两种实现方法(二)
- Android:将数字画在图片上合成一张图的两种实现方法(一)
- php 分享两种给图片加水印的方法
- php fckeditor 上传文件(或图片)中文显示为乱码的解决方法(两种方法)
- UIKit和CoCos2d 两种情况下 Retina模式图片的命名方法区别
- PHP防止图片盗用/盗链的两种方法
- 拉伸图片的两种方法
- python 读取并显示图片的两种方法
- WPF 下两种图片合成或加水印的方式
- python 读取并显示图片的两种方法
- 使用jquery获取网页中图片高度的两种方法
- 课堂实践2:运用"图像蒙版"的方法,合成Apple-Mauth图片。
- 水晶报表图片不显示两种问题分析及解决方法
- 屏蔽网页图片工具栏的两种方法
- asp.net中把有图片的execl导入到数据库(以二进制流的方式存放图片)中的两种方法
- C# 判断两张图片是否一致的两种方法
- 使用jquery获取网页中图片高度的两种方法