iphone app开发经验(三)
程序员文章站
2024-03-24 12:55:22
...
[url=http://www.iphone-geek.cn/%E6%8A%80%E5%B7%A7%E4%B8%8E%E6%8F%90%E7%A4%BA/xcode%E4%B9%8B%E5%AE%8F]1.xcode之宏[/url]
2.怎样从ipa中提取PNG文件
3.CALayer简单教程
4.两个有用的颜色
[UIColor colorWithRed:0.75 green:0.75 blue:0.75 alpha:1.0], // Silver
[UIColor colorWithRed:1.00 green:0.84 blue:0.00 alpha:1.0], // Gold
5.在 cocos2d 中将屏幕内容截取为图片
6.禁止锁屏
2.怎样从ipa中提取PNG文件
3.CALayer简单教程
4.两个有用的颜色
[UIColor colorWithRed:0.75 green:0.75 blue:0.75 alpha:1.0], // Silver
[UIColor colorWithRed:1.00 green:0.84 blue:0.00 alpha:1.0], // Gold
5.在 cocos2d 中将屏幕内容截取为图片
+ (UIImage*) screenshotUIImage
{
CGSize displaySize = [[CCDirector sharedDirector] displaySizeInPixels];
CGSize winSize = [[CCDirector sharedDirector] winSizeInPixels];
//Create buffer for pixels
GLuint bufferLength = displaySize.width * displaySize.height * 4;
GLubyte* buffer = (GLubyte*)malloc(bufferLength);
//Read Pixels from OpenGL
glReadPixels(0, 0, displaySize.width, displaySize.height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
//Make data provider with data.
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer, bufferLength, NULL);
//Configure image
int bitsPerComponent = 8;
int bitsPerPixel = 32;
int bytesPerRow = 4 * displaySize.width;
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
CGImageRef iref = CGImageCreate(displaySize.width, displaySize.height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);
uint32_t* pixels = (uint32_t*)malloc(bufferLength);
CGContextRef context = CGBitmapContextCreate(pixels, winSize.width, winSize.height, 8, winSize.width * 4, CGImageGetColorSpace(iref), kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGContextTranslateCTM(context, 0, displaySize.height);
CGContextScaleCTM(context, 1.0f, -1.0f);
switch ([CCDirector sharedDirector].deviceOrientation)
{
case CCDeviceOrientationPortrait: break;
case CCDeviceOrientationPortraitUpsideDown:
CGContextRotateCTM(context, CC_DEGREES_TO_RADIANS(180));
CGContextTranslateCTM(context, -displaySize.width, -displaySize.height);
break;
case CCDeviceOrientationLandscapeLeft:
CGContextRotateCTM(context, CC_DEGREES_TO_RADIANS(-90));
CGContextTranslateCTM(context, -displaySize.height, 0);
break;
case CCDeviceOrientationLandscapeRight:
CGContextRotateCTM(context, CC_DEGREES_TO_RADIANS(90));
CGContextTranslateCTM(context, displaySize.height-displaySize.width, -displaySize.height);
break;
}
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, displaySize.width, displaySize.height), iref);
CGImageRef imageRef = CGBitmapContextCreateImage(context);
UIImage *outputImage = [[[UIImage alloc] initWithCGImage:imageRef] autorelease];
//Dealloc
CGImageRelease(imageRef);
CGDataProviderRelease(provider);
CGImageRelease(iref);
CGColorSpaceRelease(colorSpaceRef);
CGContextRelease(context);
free(buffer);
free(pixels);
return outputImage;
}
6.禁止锁屏
[UIApplication sharedApplication].idleTimerDisabled=YES;
推荐阅读
-
iphone app开发经验(三)
-
Android APP 开发技术阶段总结(三)
-
三年高级开发,六年成为架构师,到CTO我用了12年 博客分类: 架构师经验 java架构师
-
Android开发之开发者头条APP(三)实现首页
-
Android开发之开发者头条APP(三)实现首页
-
标准的苹果式垄断:投入iPhone SDK开发前,请三思! 博客分类: iPhone AndroidApple腾讯音乐框架
-
app后端开发三:laravel中使用百度的消息推送
-
三人做了一款独立游戏,灵感来源triple,玩法不一样,H5开发,第三天在策略类新品排第一,但第四天有下降趋势,由于是第一次做,对推广没经验,希望大伙指点,手游应该怎么推广?
-
iOS开发【完美世界】面试经验:第一轮就有三个 1对1
-
大神为三星Galaxy Note 10开发APP:挖孔屏变为水滴屏