<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>爱周末 &#187; ios</title>
	<atom:link href="http://zhoumo123.cn/category/ios/feed" rel="self" type="application/rss+xml" />
	<link>http://zhoumo123.cn</link>
	<description>知识分享，共同进步。zhoumo123.cn</description>
	<lastBuildDate>Thu, 07 Nov 2019 05:53:49 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.1</generator>
	<item>
		<title>IOS视频抓图方法IOS截图代码</title>
		<link>http://zhoumo123.cn/ios/3060.html</link>
		<comments>http://zhoumo123.cn/ios/3060.html#comments</comments>
		<pubDate>Wed, 01 Jul 2015 03:25:37 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[ios]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3060</guid>
		<description><![CDATA[在iOS 软件开发中如何在视频中抓图呢？视频技术占领非常广的地位，而我们经常在播放视频的过程中，需要执行很多个功能，入视频回放、视频抓图、等 。下面是ios视频截图方法。 #pragma mark &#8211; 执行视频抓图操作方法 http://mmm0m.iteye.com/blog/2223037]]></description>
				<content:encoded><![CDATA[<p>在iOS 软件开发中如何在视频中抓图呢？视频技术占领非常广的地位，而我们经常在播放视频的过程中，需要执行很多个功能，入视频回放、视频抓图、等 。下面是ios视频截图方法。</p>
<p>#pragma mark &#8211; 执行视频抓图操作方法</p>
<pre class="brush: java; title: ; notranslate">
/*
抓图方法一
*/

static int i = 0;
-(UIImage*)screenShotView{
UIGraphicsBeginImageContextWithOptions(imageView1.frame.size, YES, 0);
[imageView1.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

CGImageRef imageRef = viewImage.CGImage;

//设置截图的区域
CGRect rect = CGRectMake(imageView1.frame.origin.x, imageView1.frame.origin.y, imageView1.frame.size.width, imageView1.frame.size.height);

CGImageRef imageRefRect = CGImageCreateWithImageInRect(imageRef, rect);
UIImage *image = [[UIImage alloc]initWithCGImage:imageRefRect];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);//保存到图片库
NSData *imageViewData = UIImagePNGRepresentation(image);

//设置保存路径
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
NSString *pictureName = [NSString stringWithFormat:@&quot;showimage_%d.png&quot;,i];
NSString *saveImagePath =[documentPath stringByAppendingPathComponent:pictureName];
NSLog(@&quot;%@&quot;,saveImagePath);

//开始写入沙盒
[imageViewData writeToFile:saveImagePath atomically:YES];
CGImageRelease(imageRefRect);
i++;
return image;
}

/*
抓图方法二
*/

-(UIImage*)shotIamge{
UIGraphicsBeginImageContext(imageView1.frame.size);
[imageView1.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *showImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

// 存入相册当中
// UIImageWriteToSavedPhotosAlbum(showImage, nil, nil, nil);

//写入沙盒当中
NSData *imageData = UIImagePNGRepresentation(showImage);

//设置路径
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];

//获取当前的时间点
NSDate *date = [NSDate date];
NSDateFormatter *forMatter = [[NSDateFormatter alloc]init];
[forMatter setDateFormat:@&quot;YYYY-MM-dd/HH:mm:ss:mm&quot;];
NSString *nowData=[forMatter stringFromDate:date];

NSString *pictureName = [NSString stringWithFormat:@&quot;%@.png&quot;,nowData];
NSString *saveImagePath =[documentPath stringByAppendingPathComponent:pictureName];
// NSLog(@&quot;saveImagePath:%@&quot;,saveImagePath);
// NSLog(@&quot;imageData:%@&quot;,imageData);

//存入沙盒
BOOL yes = [imageData writeToFile:saveImagePath atomically:YES];
if (yes) {
NSLog(@&quot;%hhd&quot;,yes);
NSLog(@&quot;存入沙盒成功&quot;);
}else{
NSLog(@&quot;%hhd&quot;,yes);
NSLog(@&quot;存入沙盒失败&quot;);
}

Image *m = [[Image alloc]init];
m.I_ImageName = pictureName;

// 将图片名字的model类存入数据库
[[ImageBaseCtl sharedDataBase]AddDataDeviceInfoToDataBase:m];

return showImage;

}
</pre>
<p>http://mmm0m.iteye.com/blog/2223037</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/ios/3060.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
