iphone镜子反射效果
来源:互联网 发布:如何做一名淘宝客 编辑:程序博客网 时间:2024/04/27 18:35
Sample: TheElements
file:///Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_0.iOSLibrary.docset/Contents/Resources/Documents/samplecode/TheElements/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007419
reflectedImageRepresentationWithHeight 返回图片指定高度的倒影
CGImageRef AEViewCreateGradientImage (int pixelsWide, int pixelsHigh){CGImageRef theCGImage = NULL; CGContextRef gradientBitmapContext = NULL; CGColorSpaceRef colorSpace;CGGradientRef grayScaleGradient;CGPoint gradientStartPoint, gradientEndPoint;// Our gradient is always black-white and the mask// must be in the gray colorspace colorSpace = CGColorSpaceCreateDeviceGray();// create the bitmap context gradientBitmapContext = CGBitmapContextCreate (NULL, pixelsWide, pixelsHigh, 8, 0, colorSpace, kCGImageAlphaNone);if (gradientBitmapContext != NULL) {// define the start and end grayscale values (with the alpha, even though// our bitmap context doesn't support alpha the gradient requires it)CGFloat colors[] = {0.0, 1.0,1.0, 1.0,};// create the CGGradient and then release the gray color spacegrayScaleGradient = CGGradientCreateWithColorComponents(colorSpace, colors, NULL, 2);// create the start and end points for the gradient vector (straight down)gradientStartPoint = CGPointZero;gradientEndPoint = CGPointMake(0,pixelsHigh);// draw the gradient into the gray bitmap contextCGContextDrawLinearGradient (gradientBitmapContext, grayScaleGradient, gradientStartPoint, gradientEndPoint, kCGGradientDrawsAfterEndLocation);// clean up the gradientCGGradientRelease(grayScaleGradient);// convert the context into a CGImageRef and release the// contexttheCGImage=CGBitmapContextCreateImage(gradientBitmapContext);CGContextRelease(gradientBitmapContext);}// clean up the colorspaceCGColorSpaceRelease(colorSpace);// return the imageref containing the gradient return theCGImage;}- (UIImage *)reflectedImageRepresentationWithHeight:(NSUInteger)height{CGContextRef mainViewContentContext; CGColorSpaceRef colorSpace; colorSpace = CGColorSpaceCreateDeviceRGB();// create a bitmap graphics context the size of the image mainViewContentContext = CGBitmapContextCreate (NULL, self.bounds.size.width,height, 8,0, colorSpace, kCGImageAlphaPremultipliedLast);// free the rgb colorspace CGColorSpaceRelease(colorSpace);if (mainViewContentContext==NULL)return NULL;// offset the context. This is necessary because, by default, the layer created by a view for// caching its content is flipped. But when you actually access the layer content and have// it rendered it is inverted. Since we're only creating a context the size of our // reflection view (a fraction of the size of the main view) we have to translate the context the// delta in size, render it, and then translate back (we could have saved/restored the graphics // stateCGFloat translateVertical=self.bounds.size.height-height;CGContextTranslateCTM(mainViewContentContext,0,-translateVertical);// render the layer into the bitmap context[self.layer renderInContext:mainViewContentContext];// translate the context backCGContextTranslateCTM(mainViewContentContext,0,translateVertical);// Create CGImageRef of the main view bitmap content, and then// release that bitmap contextCGImageRef mainViewContentBitmapContext=CGBitmapContextCreateImage(mainViewContentContext);CGContextRelease(mainViewContentContext);// create a 2 bit CGImage containing a gradient that will be used for masking the // main view content to create the 'fade' of the reflection. The CGImageCreateWithMask// function will stretch the bitmap image as required, so we can create a 1 pixel wide// gradientCGImageRef gradientMaskImage=AEViewCreateGradientImage(1,height);// Create an image by masking the bitmap of the mainView content with the gradient view// then release the pre-masked content bitmap and the gradient bitmapCGImageRef reflectionImage=CGImageCreateWithMask(mainViewContentBitmapContext,gradientMaskImage);CGImageRelease(mainViewContentBitmapContext);CGImageRelease(gradientMaskImage);// convert the finished reflection image to a UIImage UIImage *theImage=[UIImage imageWithCGImage:reflectionImage];// image is retained by the property setting above, so we can // release the originalCGImageRelease(reflectionImage);// return the imagereturn theImage;}
- iphone镜子反射效果
- Unity 镜子反射特效
- 页面镜子效果
- irrlicht引擎:镜子效果
- TopCoder--镜子反射路径问题.
- VS2008,C++,镜子反射 光线反射游戏
- android 图形平移 镜子效果 倒影效果
- Android Bitmap镜子效果、倒影效果
- 镜子
- 镜子
- 镜子
- Stenciling技术实现镜子效果 图形学1
- D3D中镜子效果的实现
- android(39)(创建图形的拷贝、旋转、镜子效果、颜色变化)
- AS3 倒影效果(反射效果)
- 百度镜子
- 镜子小游戏
- “手机镜子”
- ThreadLocal了解和几种常见误区
- Redis源代码分析之一:内存管理——Zmalloc
- 字节对齐问题
- Shell Test命令参数解析
- java 基本原理 积累
- iphone镜子反射效果
- Shell 脚本小常识1
- QS0001-2012 瞿氏标准(Qu's Standards)编号规范
- 我的贪食蛇
- android.view.WindowLeaked: Activity com.android.browser.AddBookmarkPage has leaked window com.androi
- 选择排序
- 怎样才是有效沟通
- eclipse 显示 空格 .回车符号,去掉相应的符号
- ORACLE 空间维护