core-graphics

iPhone UIView replace image color programmatically, like in Photoshop or Illustrator

人走茶凉 提交于 2019-12-04 13:54:32
I have a set of graphics that I would like to reuse within my apps. They are buttons and images with transparency. Rather than having dozens of hard-coded button images, I would love to have a single button image, and be able to assign a color to it dynamically, like the navigation bar and it's tint color. Is it possible to replace/shift the hue of a UIView? Alternatively: I know that if I overlay a transparent image over another UIView, then I can change the background color and the two images will blend together. But the transparent regions will take on the hue of the background. Is there a

iphone: Apply a texture to CGContextStrokePath

和自甴很熟 提交于 2019-12-04 13:48:56
问题 I search all the question and answer in StackOverflow but can not get the result I want. I would like to use a PNG file, to display as a stroke at the point user touch and move. This is the PNG file: But I did all the ways on StackOverflow, even using CGPatternRef, but I don't have the result I want. The result I have is here: But the result I want to have is here: This result I have done in OpenGL ES, but I can not do that in Core Graphics. I think I can use CGContextDrawImage at each point,

Applying Gradient to UIImage Smoothly

做~自己de王妃 提交于 2019-12-04 13:18:22
问题 I am trying to apply gradient to UIImage using CoreGraphic; however, the result I got is not very nice. I want to create a black to transparent gradient at the bottom of the image to create a contrast for me to place some text. However, the gradient I was able doesn't blend well with the image; you can clearly see the separation in the center . The result I am looking for is like this application: http://capptivate.co/2014/02/17/yummly-3/ How should I apply the gradient to achieve this? ( I

Framebuffer/Color Buffer?

流过昼夜 提交于 2019-12-04 13:17:58
Can someone point out to me if both of them are the same? I mean I have been reading info about it and this redbook here says "The color buffer itself can consist of several subbuffers. The framebuffer on a system comprises all of these buffers" here Is framebuffer then like a virtual buffer consisting of all the actual buffers ?(like depth/stencil etc) The framebuffer contains (often) the depth, stencil, color, and accumulation buffers. The color buffers are the most important part, but they are only one part. You can create more color buffers, and you can also create more framebuffers in

Is there an alternative to CGPath which allows to compute points on a path for a given location?

。_饼干妹妹 提交于 2019-12-04 13:17:51
For an animation timing algorithm I need to supply a path as the curve. Probably a bezier curve with control points on both ends. The problem is that it seems not possible to calculate points on a CGPath because CGPathRef is opaque. Also Apple provides no mechanism to compute points on a path. Is there a library or utility class which can compute points on a bezier curve or path, for a given location like 0.5 for the middle along the path? Or let me rephrase it: If CGPath / CGPathRef makes this impossible because it is opaque, and if you only care about bezier curves, is there a way to compute

CGContextDrawImage draws large images very blurry

拥有回忆 提交于 2019-12-04 12:45:30
I'm trying to make an object that can draw a portion of a large (say 2048 x 1537) image using CGContextDrawImage(…). It works just fine, except that it is extremely blurry. I'm using a "drawingController" which overrides drawLayer:inContext: like this -(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{ CGImageRef drawImage = CGImageRetain(imageToDraw); if(drawImage) { CGRect drawRect = CGRectMake(0, 0, 1024, 748);//Just hard coded to my window size for now. CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh); CGContextDrawImage(ctx, drawRect, drawImage); } CGImageRelease

Making CIContext.render(CIImage, CVPixelBuffer) work with AVAssetWriter

五迷三道 提交于 2019-12-04 12:44:10
I want to use Core Image for processing a bunch of CGImage objects and turning them into a QuickTime movie on macOS . The following code demonstrates what's needed, but the output contains a lot of blank (black) frames : import AppKit import AVFoundation import CoreGraphics import Foundation import CoreVideo import Metal // Video output url. let url: URL = try! FileManager.default.url(for: .downloadsDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathComponent("av.mov") try? FileManager.default.removeItem(at: url) // Video frame size, total frame count, frame rate

Swift - Playground - Core Graphics / Core Text / Custom View

风流意气都作罢 提交于 2019-12-04 12:43:13
问题 Question I'm attempting to make a custom UIView component in swift playground. I've been able to figure out how to do everything except for render text correctly. I'm not sure if i'm supposed to do this via Core Graphics or Core Text or exactly how to get it working correctly. As you can see in the image below I want to render text both upside down and right side up on either side of my custom View Component I've tried various ways to get the text to work but I keep running aground. If

How to find an arrow tip points given origin and end point of a line

◇◆丶佛笑我妖孽 提交于 2019-12-04 12:40:30
Consider you have a line with start point (x1,y1) and end point (x2,y2). In order to draw an arrow cap to the line (in objective-c), I need to find the points of the arrow (x3,y3,x4,y4) given the angle of the arrow (45 degrees), and the length of the arrow tips (h). So given x1,y1,x2,y2,h,alpha whats x3,y3,x4,y4? Added an image explaining the question. If the answer can be in objective-c (using UIBezierpath and CGPoint) it will be much appreciated. Thanks! #import <math.h> #import <UIKit/UIKit.h> #import <CoreGraphics/CoreGraphics.h> float phi = atan2(y2 - y1, x2 - x1); // substitute x1, x2,

UITableView with Transparent Gradient at Top and Bottom

时间秒杀一切 提交于 2019-12-04 12:35:41
问题 I have searched this forum, Google and other forums and have not found an the answer to my particular issue. Basically, I have a UIView which contains UITableView . I followed this tutorial and it was partially successful. The problem is the gradient. I have a background image behind the UITableView . So as the cell nears the gradient, I want the background to be showing, instead of the white. I also found this post which which is where I found the tutorial, but I didn't want to hijack that