- 浏览: 632288 次
- 性别:
- 来自: 青岛
文章分类
最新评论
-
mojingqing:
感谢!
MySQL修改my.ini后,出现错误:Incorrect information in file: '.\xx\xx.frm -
qq3061280:
qq3061280 写道
FATAL ERROR in native method: JDWP No transports i -
qq3061280:
FATAL ERROR in native method: JDWP No transports i -
xiebo1983:
http://sqkoo.com/mysql-function ...
Date format -
java_xiaoyi:
...
[SQLServer]传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确
方法一:
UIGraphicsBeginImageContextWithOptions(pageView.page.bounds.size, YES, zoomScale); [pageView.page.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *uiImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
方法二:
- (UIImage *) glToUIImage { DWScrollView *pageView = [self getActivePageView]; pageView.page.backgroundColor = [UIColor clearColor]; // self.backgroundColor=[UIColor clearColor]; NSInteger myDataLength = 320 * 308 * 4; // allocate array and read pixels into it. GLubyte *buffer = (GLubyte *) malloc(myDataLength); glReadPixels(0, 0, 320, 308, GL_RGBA, GL_UNSIGNED_BYTE, buffer); // gl renders "upside down" so swap top to bottom into new array. // there's gotta be a better way, but this works. GLubyte *buffer2 = (GLubyte *) malloc(myDataLength); for(int y = 0; y <308; y++) { for(int x = 0; x <320 * 4; x++) { if(buffer[y* 4 * 320 + x]==0) buffer2[(307 - y) * 320 * 4 + x]=1; else buffer2[(307 - y) * 320 * 4 + x] = buffer[y* 4 * 320 + x]; } } // make data provider with data. CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, myDataLength, NULL); // prep the ingredients int bitsPerComponent = 8; int bitsPerPixel = 32; int bytesPerRow = 4 * 320; CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; // make the cgimage CGImageRef imageRef = CGImageCreate(320, 308, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent); // then make the uiimage from that UIImage *myImage = [UIImage imageWithCGImage:imageRef]; UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil); return myImage; }
方法三:
// get screen - (void)grabScreen { unsigned char buffer[320*480*4]; glReadPixels(0,0,320,480,GL_RGBA,GL_UNSIGNED_BYTE,&buffer); CGDataProviderRef ref = CGDataProviderCreateWithData(NULL, &buffer, 320*480*4, NULL); CGImageRef iref = CGImageCreate(320,480,8,32,320*4,CGColorSpaceCreateDeviceRGB(),kCGBitmapByteOrderDefault,ref,NULL,true,kCGRenderingIntentDefault); CGFloat width = CGImageGetWidth(iref); CGFloat height = CGImageGetHeight(iref); size_t length = width*height*4; uint32_t *pixels = (uint32_t *)malloc(length); CGContextRef context = CGBitmapContextCreate(pixels, width, height, 8, 320*4, CGImageGetColorSpace(iref), kCGImageAlphaLast | kCGBitmapByteOrder32Big); CGContextTranslateCTM(context, 0.0, height); CGContextScaleCTM(context, 1.0, -1.0); CGContextDrawImage(context, CGRectMake(0.0, 0.0, width, height), iref); CGImageRef outputRef = CGBitmapContextCreateImage(context); UIImage *outputImage = [UIImage imageWithCGImage:outputRef]; UIImageWriteToSavedPhotosAlbum(outputImage, nil, nil, nil); CGContextRelease(context); CGImageRelease(iref); CGDataProviderRelease(ref); }
方法四:
CGImageRef UIGetScreenImage(); void SaveScreenImage(NSString *path) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; CGImageRef cgImage = UIGetScreenImage(); void *imageBytes = NULL; if (cgImage == NULL) { CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); imageBytes = malloc(320 * 480 * 4); CGContextRef context = CGBitmapContextCreate(imageBytes, 320, 480, 8, 320 * 4, colorspace, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorspace); for (UIWindow *window in [[UIApplication sharedApplication] windows]) { CGRect bounds = [window bounds]; CALayer *layer = [window layer]; CGContextSaveGState(context); if ([layer contentsAreFlipped]) { CGContextTranslateCTM(context, 0.0f, bounds.size.height); CGContextScaleCTM(context, 1.0f, -1.0f); } [layer renderInContext:(CGContextRef)context]; CGContextRestoreGState(context); } cgImage = CGBitmapContextCreateImage(context); CGContextRelease(context); } NSData *pngData = UIImagePNGRepresentation([UIImage imageWithCGImage:cgImage]); CGImageRelease(cgImage); if (imageBytes) free(imageBytes); [pngData writeToFile:path atomically:YES]; [pool release]; }
方法五:
+ (UIImage *)imageWithScreenContents { CGImageRef cgScreen = UIGetScreenImage(); if (cgScreen) { UIImage *result = [UIImage imageWithCGImage:cgScreen]; CGImageRelease(cgScreen); return result; } return nil; }转自:http://www.cocoachina.com/newbie/basic/2011/1205/3664.html
发表评论
-
开始Cordova
2016-11-08 14:00 639安装: 1.下载并安装Node.js 2.安装c ... -
swift3 GCD
2016-09-16 17:08 508Creating a concurrent queue l ... -
iTunes无法验证服务器"s.mzstatic.com."的身份
2016-09-15 09:27 478修改hosts sudo vi /etc/hosts ... -
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
2016-08-29 15:16 773在做 点击section下拉展示相应cell的功能时,遇到了 ... -
CocoaPods + XCTest进行单元测试
2016-07-21 15:53 2393在使用XCTest进行单元测试时,我们经常会遇到一些Coco ... -
关于vim配置及插件
2016-06-07 17:05 460比较好的配置: https://github.co ... -
Couldnt communicate with helper application Git提交
2016-05-09 09:22 600Xcode需要设置 email和用户名,在终端中设置如下: ... -
OC 单元测试断言
2016-04-22 18:04 733XCTFail(format…) 生成一个失败的测试; ... -
git Xcode
2016-04-19 10:06 591显示隐藏的文件夹 defaults write com.a ... -
AppleWWDRCA.cer 过期
2016-02-19 14:40 699下载 https://developer.appl ... -
调试SIGABRT和EXC_BAD_ACCESS crash
2015-12-15 20:08 8491. SIGABRT是处于程序控 ... -
网易客户端链接
2015-11-18 10:24 902财经 http://c.m.163.com/nc/arti ... -
网易新闻iOS版使用的开源组件
2015-11-18 09:58 754网易新闻iOS版在开发过程中曾经使用过的第三方开源类库、组件 ... -
控件按照路径回落(类似Mac App store某软件的安装弹跳动画)
2015-11-16 09:40 770- (void)animateSnapshotOfView: ... -
anchorPoint与position
2015-11-12 15:07 528anchorPoint: (0,0) 坐标原点;(1,1) ... -
Code Snippets的备份
2015-10-29 17:53 592Xcode中的Code Snippets 默认目录: ~/ ... -
Xcode 7 BitCode
2015-10-19 01:10 522在Xcode 7中,我们新建一个iOS程序时,bitcode ... -
删除Xcode DerivedData目录释放空间
2015-09-17 17:59 1034首先切换到 Finder 程序,打开“前往”菜单。 ... -
UILabel 竖排
2015-08-10 09:35 811labelObject.numberOfLines = 0 ... -
app icon
2015-06-01 22:43 504Table 41-1Size (in pixels ...
相关推荐
ios iphone 源码 iphone桌面截图代码
Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码——iPhone版Wordpress源代码Iphone开发系列源码...
iphone_UI源代码 iphone_UI源代码 iphone_UI源代码 iphone_UI源代码
iphone二维码扫码代码。好东西现在国家大力推行二维码。
iphone文件下载模块代码例子文件下载模块代码例子文件下载模块代码例子文件下载模块代码例子文件下载模块代码例子文件下载模块代码例子
iphone 基础开发源代码Beginning iPhone Dev Aug 2 2009 iphone 基础开发源代码Beginning iPhone Dev Aug 2 2009 iphone 基础开发源代码Beginning iPhone Dev Aug 2 2009
iphone NanoLife粒子 源代码 iphone NanoLife粒子 源代码 iphone NanoLife粒子 源代码
iphone 重力感应代码 iphone 重力感应代码 iphone 重力感应代码
iPhone弹球游戏源代码
iPhone 创建地图 源代码 如何创建地图例子源代码
苹果Iphone常见的重启数据分析代码 包含苹果机型重启分析代码(i2c总线报错)
IPHONE下拉刷新列表代码,可以实现上拉下啦刷新table效果。
Iphone开发系列源码——星级评价实现代码Iphone开发系列源码——星级评价实现代码Iphone开发系列源码——星级评价实现代码Iphone开发系列源码——星级评价实现代码Iphone开发系列源码——星级评价实现代码Iphone开发...
电脑需预先安装JDK 空间说说由iPhone发表,Java源代码
iphone开发基础教程的源代码,代码已经编译通过。
iPhone 定位 位置变化捕获 定位到设备的位置,并捕获位置的变化例子源代码
iPhone 游戏 源代码 分享一下iphone游戏的源代码 为大家学习提供帮助
iphone打开pdf文件代码例子,iphone打开pdf文件代码例子
兼容 IPhone8 兼容 IPhone8 兼容 IPhone8 兼容 IPhone8 兼容 IPhone8 兼容 IPhone8 兼容 IPhone8 兼容 IPhone8
零点起飞学iPhone开发随书源代码仅供学习使用