图片切成两个图 9os-immage
来源:互联网 发布:基于单片机电子密码锁 编辑:程序博客网 时间:2024/04/28 13:21
+(NSArray *)splitImageIntoTwoParts:(UIImage *)image
{
CGFloat scale = [[UIScreen mainScreen] scale];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:2];
CGFloat width,height,widthgap,heightgap;
int piceCount = SAWTOOTH_COUNT;
width = image.size.width;
height = image.size.height;
widthgap = 0;//width/SAWTOOTH_WIDTH_FACTOR;
heightgap = height/piceCount;
// CGRect rect = CGRectMake(0, 0, width, height);
CGContextRef context;
CGImageRef imageMasked;
UIImage *leftImage,*rightImage;
//part one
UIGraphicsBeginImageContext(CGSizeMake(width*scale, height*scale));
context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scale, scale);
CGContextMoveToPoint(context, 0, 0);
int a=-1;
for (int i=0; i<piceCount+1; i++) {
CGContextAddLineToPoint(context, width/2+(widthgap*a), heightgap*i);
a= a*-1;
}
CGContextAddLineToPoint(context, 0, height);
CGContextClosePath(context);
CGContextClip(context);
[image drawAtPoint:CGPointMake(0, 0)];
imageMasked = CGBitmapContextCreateImage(context);
leftImage = [UIImage imageWithCGImage:imageMasked scale:scale orientation:UIImageOrientationUp];
[array addObject:leftImage];
UIGraphicsEndImageContext();
//part two
UIGraphicsBeginImageContext(CGSizeMake(width*scale, height*scale));
context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scale, scale);
CGContextMoveToPoint(context, width, 0);
a=-1;
for (int i=0; i<piceCount+1; i++) {
CGContextAddLineToPoint(context, width/2+(widthgap*a), heightgap*i);
a= a*-1;
}
CGContextAddLineToPoint(context, width, height);
CGContextClosePath(context);
CGContextClip(context);
[image drawAtPoint:CGPointMake(0, 0)];
imageMasked = CGBitmapContextCreateImage(context);
rightImage = [UIImage imageWithCGImage:imageMasked scale:scale orientation:UIImageOrientationUp];
[array addObject:rightImage];
UIGraphicsEndImageContext();
return array;
}
{
CGFloat scale = [[UIScreen mainScreen] scale];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:2];
CGFloat width,height,widthgap,heightgap;
int piceCount = SAWTOOTH_COUNT;
width = image.size.width;
height = image.size.height;
widthgap = 0;//width/SAWTOOTH_WIDTH_FACTOR;
heightgap = height/piceCount;
// CGRect rect = CGRectMake(0, 0, width, height);
CGContextRef context;
CGImageRef imageMasked;
UIImage *leftImage,*rightImage;
//part one
UIGraphicsBeginImageContext(CGSizeMake(width*scale, height*scale));
context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scale, scale);
CGContextMoveToPoint(context, 0, 0);
int a=-1;
for (int i=0; i<piceCount+1; i++) {
CGContextAddLineToPoint(context, width/2+(widthgap*a), heightgap*i);
a= a*-1;
}
CGContextAddLineToPoint(context, 0, height);
CGContextClosePath(context);
CGContextClip(context);
[image drawAtPoint:CGPointMake(0, 0)];
imageMasked = CGBitmapContextCreateImage(context);
leftImage = [UIImage imageWithCGImage:imageMasked scale:scale orientation:UIImageOrientationUp];
[array addObject:leftImage];
UIGraphicsEndImageContext();
//part two
UIGraphicsBeginImageContext(CGSizeMake(width*scale, height*scale));
context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scale, scale);
CGContextMoveToPoint(context, width, 0);
a=-1;
for (int i=0; i<piceCount+1; i++) {
CGContextAddLineToPoint(context, width/2+(widthgap*a), heightgap*i);
a= a*-1;
}
CGContextAddLineToPoint(context, width, height);
CGContextClosePath(context);
CGContextClip(context);
[image drawAtPoint:CGPointMake(0, 0)];
imageMasked = CGBitmapContextCreateImage(context);
rightImage = [UIImage imageWithCGImage:imageMasked scale:scale orientation:UIImageOrientationUp];
[array addObject:rightImage];
UIGraphicsEndImageContext();
return array;
}
- 图片切成两个图 9os-immage
- 图片切成圆形图
- Unity3D NGUI图集切成图片
- 将图片切成圆形
- 正方形图片切成圆形
- 把图片切成小片(IOS)
- 工具类-将图片切成圆形图片
- 把图片切成圆角代码
- 把图片切成圆角代码
- 把图片切成圆角的代码
- 把图片切成圆角代码
- 把图片切成圆角代码
- 把图片切成圆角代码
- 把图片切成圆角代码
- 把图片切成圆角代码
- 把图片切成圆角代码
- 把图片切成圆角的代码
- 用Photoshop把图片切成圆角
- GStreamer 编写一个简单的MP3播放器
- 查看android所有分支的方法
- 【CakePHP1.3】_文件名、类名约定
- Linux下MemCached安装和启动以及C#调用
- PowerDesigner建立与数据库的连接,以便生成数据库和从数据库生成到PD中。[Oracle 10G版]
- 图片切成两个图 9os-immage
- 一堂价值300万元的课,如果你能有耐心把它看完,必定受益匪浅。。。
- RelativeLayout用到的一些重要的属性
- Android应用程序架构
- pktgen 测试网速
- 腾讯网络编辑入门指点
- UIImage 图片处理:截图,缩放,设定大小,存储
- 数据库备份问题 媒体集有 2 个媒体簇,但只提供了 1 个
- (自用型)windows/linux网络编程通用跨平台头文件定义