core-graphics

“renderInContext:” and CATransform3D

半腔热情 提交于 2019-12-09 04:27:23
问题 I have an view that have mutiples views inside it, and an image presentation (aka. 'cover flow') into that too... And I need to make a screenshot programatically ! Since docs says that "renderInContext:" will not render 3d animations : "Important The Mac OS X v10.5 implementation of this method does not support the entire Core Animation composition model. QCCompositionLayer, CAOpenGLLayer, and QTMovieLayer layers are not rendered. Additionally, layers that use 3D transforms are not rendered,

Core Text: Render to an Odd Shape

主宰稳场 提交于 2019-12-09 00:57:26
问题 I am trying to render text to a shape that isn't a rectangle. The following code works when I add a rectangular path but not when I add an elliptical path. Ultimately, I'd like to draw to any path (L shape, etc), has anyone had any luck with this? -(void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetTextMatrix(context, CGAffineTransformIdentity); CGMutablePathRef path = CGPathCreateMutable(); float w = 200.0; float h = 300.0; CGRect bounds =

Flatten CALayer sublayers into one layer

本小妞迷上赌 提交于 2019-12-09 00:21:01
问题 In my app I have one root layer, and many images which are sublayers of rootLayer. I'd like to flatten all the sublayers of rootLayer into one layer/image, that don't have any sublayers. I think I should do this by drawing all sublayers in core graphics context, but I don't know how to do that. I hope you'll understand me, and sorry for my English. 回答1: From your own example for Mac OS X: CGContextRef myBitmapContext = MyCreateBitmapContext(800,600); [rootLayer renderInContext:myBitmapContext

Core Image CIColorControls brightness filter creates wrong effect. How do I change my image's luminance?

偶尔善良 提交于 2019-12-08 22:50:58
问题 I'm creating a color picker for iOS. I would like to enable the user to select the brightness (luminance) and have the color wheel reflect this change. I'm using Core Image to modify the brightness with the CIColorControls filter. Here's my code: -(CIImage *)oldPhoto:(CIImage *)img withBrightness:(float)intensity { CIFilter *lighten = [CIFilter filterWithName:@"CIColorControls"]; [lighten setValue:img forKey:kCIInputImageKey]; [lighten setValue:@((intensity * 2.0) - 1.0) forKey:@

Finding min/max of quadratic bezier with CoreGraphics

百般思念 提交于 2019-12-08 17:39:58
问题 I am using CoreGraphics to draw a quadratic bezier but want to computer the min/max value of the curve. I am not from a mathematical background so this has become a bit troublesome. Does anyone have any articles or ideas about how to solve this? 回答1: For a quadratic Bezier, this is actually quite simple. Define your three control points as P0 = (x0,y0) , P1 = (x1,y1) and P2 = (x2,y2) . To find the extrema in x , solve this equation: t = (x0 - x1) / (x0 - 2*x1 + x2) If 0 <= t <= 1 , then

UIGraphicsBeginImageContext must be Retina-aware?

拟墨画扇 提交于 2019-12-08 15:49:05
问题 I've read some posts which recommend the use of: UIGraphicsBeginImageContextWithOptions((image.size), NO, 0.0f) instead of: UIGraphicsBeginImageContext(image.size). Because the first one uses Retina-scale when drawing, otherwise you get blocky images. I'm a little confused about when to use or not the retina-scale option. If i have a photograph which is 1000x1000 px, and i call UIGraphicsBeginImageContext passing those dimensions, am i not specifying exactly how many points i want to draw? Is

Why does the iphone CGImageCreate with data from standard BMP bits give the wrong result?

半腔热情 提交于 2019-12-08 14:32:23
问题 i have a gdi engine that result in the standard bmp bits stream ,and now i wanna to display it by the CG in iphone , i use it like this: // size -> image size // rect -> current view rect // pBits -> the BITMAPINFO image bits stream long imgSizePerRow = ((long)(24 * size.width + 31) / 32) * 4; CGDataProviderRef providerRef = CGDataProviderCreateWithData(NULL, pBits, imgSizePerRow * size.height, NULL); CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGImageRef imageRef =

Convert image to Black and white IOS?

£可爱£侵袭症+ 提交于 2019-12-08 13:57:28
问题 I have found lots of code to convert image to pure black and white. but none this working. I have tried this code but its convert image to grayscale not black and white. -(UIImage *)convertOriginalImageToBWImage:(UIImage *)originalImage { UIImage *newImage; CGColorSpaceRef colorSapce = CGColorSpaceCreateDeviceGray(); CGContextRef context = CGBitmapContextCreate(nil, originalImage.size.width * originalImage.scale, originalImage.size.height * originalImage.scale, 8, originalImage.size.width *

How to draw on two separate layers iOS, coregraphics

无人久伴 提交于 2019-12-08 12:48:51
问题 I need help with drawing something like this: I have been told that the gray background bar and the purple bar should be drawn on separate layers. And then the dots there that signifies the chapters of a book (which this slider is about) will be on a layer on top of those two. I have accomplished the task of creating the gradient on the active bar and drawing it like so: - (void)drawRect:(CGRect)rect{ self.opaque=NO; CGRect viewRect = self.bounds; //NSLog(@"innerRect width is: %f", innerRect

How do i save an UIImage as a BMP file in documents directory

北慕城南 提交于 2019-12-08 12:04:22
问题 Similar questions has been asked but they always contain the answer "use UIImagePNGRepresentation or UIImageJPEGRepresentation" But that wont work for me since i have to send this file to an external webservice that only accepts BMP images. This is what i have implemented so far -(NSData*)getBitmapRepresentationFromUIImage:(UIImage*)img{ CGImageRef cgiImg =[img CGImage]; CGColorSpaceRef colorSpaceRef = CGImageGetColorSpace(cgiImg); size_t bitsPerComponent = CGImageGetBitsPerComponent(cgiImg);