core-graphics

IKImageView redraw problem on image change

大兔子大兔子 提交于 2019-12-11 19:24:04
问题 I have one large IKImageView in my window. The image changes when the user clicks something. When the change happens, the IKImageView first draws the background colour, then draws the image over the top of it, which looks pretty crappy. Is there a way to get it to switch images more smoothly? It also contains garbage when the window loads for a split second until the image loads - is this related? 回答1: Problem solved - stop using IKImageView and never bother with it again because it is poorly

How can I animate a UIColor in a CALayer?

对着背影说爱祢 提交于 2019-12-11 18:46:52
问题 I have a custom CALayer within which I'm trying to enable the animation of certain properties using actionForKey and following this tutorial. I have a CGFloat property that will change perfectly when inside an animation block but my other property, a UIColor , will not. Here's my function: - (id<CAAction>)actionForKey:(NSString *)event { if ([self presentationLayer] != nil && [[self class] isCustomAnimationKey:event]) { id animation = [super actionForKey:@"backgroundColor"]; if (animation ==

In iOS Core Graphics, what is a graphicsContext?

China☆狼群 提交于 2019-12-11 17:48:39
问题 When we do: CGContextRef ctx = UIGraphicsGetCurrentContext(); what exactly is ctx? Apparently it's a struct. Where is the struct defined? What are its members? 回答1: It is a pointer to a struct. The struct is opaque. Just use the functions connected with it. 回答2: What is a graphics context? A graphics context refers to the graphic destination. Destination can be a window in an application, a bitmap image, a PDF document, or a printer. If you want to draw on a view, the view is your

CGFontGetGlyphBBoxes wrong result

纵然是瞬间 提交于 2019-12-11 17:05:34
问题 I have been trying to measure glyph bounds precisely but this code prints out 916!!! The real width of this is 69. - (void)drawRect:(NSRect)dirtyRect { CGContextRef main = [[NSGraphicsContext currentContext] graphicsPort]; CGContextSetTextMatrix(main, CGAffineTransformIdentity); CGGlyph g; CGPoint p = CGPointMake(100, 100); CGRect rect = CGRectMake(0, 0, 0, 0); CGFontRef font = CGFontCreateWithFontName((CFStringRef)@"Arial"); g = CGFontGetGlyphWithGlyphName(font, CFSTR("L")); CGContextSetFont

Reading and editing pixels of image on iPhone

╄→尐↘猪︶ㄣ 提交于 2019-12-11 16:31:08
问题 Curious about how to read and edit a picture's pixels on the iPhone. Am I better of using an array of points with colours? I want to do things like.. if a CGPoint intersects with a "brown" spot on the picture, set the colour of all brown pixels in a radius to white. More questions to come, but this is a start. Cheers 回答1: The picture data is available to you as precisely that -- a two-dimensional array of pixels, each pixel being represented by a 32 bit integer. For each of the color

Why did the SDWebImage redraw imageSource in the connection:didReceiveData: method?

只愿长相守 提交于 2019-12-11 15:55:10
问题 look at the code snippet below. i don't understand the code between #ifdef TARGET_OS_IPHONE and #endif,should i redraw a new image from the imageSource? why? - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [self.imageData appendData:data]; if ((self.options & SDWebImageDownloaderProgressiveDownload) && self.expectedSize > 0 && self.completedBlock) { // Get the total bytes downloaded const NSInteger totalSize = self.imageData.length; // Update the data source,

UIGraphicsBeginImageContext created image stays in memory forever

假如想象 提交于 2019-12-11 14:52:31
问题 I'm creating many colour variations of an image using Core Graphics. I need to create about 320 in total but gradually, the memory usage of the app keeps increasing until it crashes. From Instruments, I see that more CGImage objects are being created and stay alive. I want to release them because I store the images to the cache directory in PNG format. I have searched through all other solutions I could find without success. Any help is appreciated. Thanks. Here's the main part: +(UIImage *

Moving/Rotating an object using it's updated position and tilt?

◇◆丶佛笑我妖孽 提交于 2019-12-11 14:43:14
问题 This is basically a simple issue, which I can't get around ... So, I have an object of UIImageView of a certain frame over which, I implement CAAnimation with rotation and translation, and it is at new coordinates (x,y), and has been rotated by some degrees. This animation works beautifully. But if I again do a rotation and movement from THAT state, I want the object to use the new frame and new properties from STEP 1 after its rotation and again rotate by the new angle. As of now, when I try

IOS 5: UIView converted to video and the resulting video is corrupted

三世轮回 提交于 2019-12-11 12:42:24
问题 I want to grab the UIView, convert to image and than store that image in a video file (.mp4). I use the next portion of code which grabs the image and puts it to pixel buffer: BOOL appended; if(input.readyForMoreMediaData==YES){ //grab the view and convert it into image CGSize imgsize=self.imageSource.frame.size; UIGraphicsBeginImageContext(imgsize); [self.imageSource.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage* grabbedImage = UIGraphicsGetImageFromCurrentImageContext();

EXC_BAD_ACCESS while using CoreAnimation

依然范特西╮ 提交于 2019-12-11 11:54:10
问题 I use CoreAnimation to animate UIImageView (curve Bezier animation). Here`s my code: CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.calculationMode = kCAAnimationCubic; pathAnimation.fillMode = kCAFillModeForwards; pathAnimation.removedOnCompletion = NO; CGPoint endPoint = originalPosition; UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:star.layer.position]; [path addQuadCurveToPoint:endPoint controlPoint