core-graphics

How to change Brightness, Contrast and Saturation using CIColorControls via UISlider with Swift

馋奶兔 提交于 2019-12-07 20:59:28
问题 I'm working on a Photo Filter App and as you can see I added a feature to adjust contrast, brightness, saturation, and noise. But the problem is they work independently, which means when I'm adjusting let's say brightness as soon as I start editing contrast, it returns to the original brightness. Here is a preview when I'm putting the brightness to the maximum (the image gets white) and then trying to adjust its contrast and the slider changes the contrast of an original image. Here I was

Rendering UIImage/CGImage into CGPDFContext results in… blankness!

不想你离开。 提交于 2019-12-07 19:28:19
问题 I'm trying to take an image that I have in a image object and render into a Core Graphics PDF context-- happens to be on an iPhone but this question surely applies equally to desktop Quartz. This UIImage is a simple color-on-white image at about 600x800 resolution. If I (say) turn it into a PNG file, that file looks exactly as expected-- so the data is OK. Here's what I'm doing to generate the PDF: NSMutableData * outputData = [[NSMutableData alloc] init]; CGDataConsumerRef dataConsumer =

How to draw a UILabel with a different blend mode in draw(_ rect: CGRect) in Swift

一曲冷凌霜 提交于 2019-12-07 18:08:59
问题 So I have a UILabel that is being drawn on top of a gradient image (that is a UIImageView ). It looks sorta like this: I'm trying to change the blendMode of the graphics context in the UILabel 's draw(_ rect: CGRect) function so that it draws the label but blended with the background with a softLight blending mode. Here is what I want it to look like: Here is the code I have in the draw(_ rect: CGRect) function: override func draw(_ rect: CGRect) { // Drawing code if let context =

draw a straight line in swift 3 and core graphics

房东的猫 提交于 2019-12-07 18:08:14
问题 I'm trying to draw a single, straight line using core graphics and swift 3 However, when touchesmoved is called, it creates multiple lines instead of just a single line. Code used is below: import UIKit class ViewController: UIViewController { @IBOutlet weak var drawingPlace: UIImageView! var startTouch : CGPoint? var secondTouch : CGPoint? override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { let touch = touches.first startTouch = touch?.location(in: drawingPlace) }

How to store an OpenGL program object's uniforms per-context instead of per-program?

天涯浪子 提交于 2019-12-07 17:43:47
问题 I'm working on a multithreaded OpenGL compositing engine. I have a set of shaders which I'm sharing among multiple contexts. For performance reasons, I'd like to avoid compiling a separate instance of each shader program for each thread. But, if multiple threads happen to use the same program object and I try to set different uniforms on each thread, the uniform values get mixed up since uniform values are stored with the shared program object. So far I see my options as: compile a separate

Creating a dropshadow for UITableView

不羁的心 提交于 2019-12-07 17:40:49
问题 Would somebody please explain how to create a one or two pixel drop shadow ONLY on the the very last cell (in other words, I don't want a shadow around the entire tableview, just the bottom cell. An image of what I'm talking about: 回答1: Solved. Use the following code to produce a very nice, subtle shadow to the bottom of your UITableViewCell . Makes it look like it's raised slightly out of the page :) UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(3, 49, cell.frame.size

Avoiding colorspace transformations when blitting, Mac OS X 10.11 SDK

一笑奈何 提交于 2019-12-07 15:55:26
问题 When using the colorspace returned from CGColorSpaceCreateDeviceRGB(), a colorspace transformation will be applied on any CGContextDrawImage() call, leading to 5-6x worse performance than blitting without this transform. To avoid this colorspace transformation, we have been using the colorspace created with the system monitor profile: CMProfileRef smp = 0; if (CMGetSystemProfile(&smp) == noErr) { colorSpace = CGColorSpaceCreateWithPlatformColorSpace(smp); CMCloseProfile(smp); } else

Get Image back from CGBitmapContextGetData

扶醉桌前 提交于 2019-12-07 15:02:17
问题 So I have a CGBitmapContext and I get the pixel at a touchlocation using this unsigned char* data = CGBitmapContextGetData (offscreenBuffer); if (data != NULL) { offset = 4*((self.bounds.size.width*round(coord.y))+round(coord.x)); int alpha = data[offset]; int red = data[offset+1]; int green = data[offset+2]; int blue = data[offset+3]; } And then I change the pixel colour like below. data[offset]=255; data[offset+1]=255; data[offset+2]=0; data[offset+3]=0; My question is how do a get a

CATiledLayer drawLayer:inContext: crashing when the view is deallocated while the image to draw is being retrieved

三世轮回 提交于 2019-12-07 11:55:31
问题 My app crashes when my ViewController gets deallocated while my CATiledLayer is retrieving the image to draw in a background thread. I get a message -[MyViewController respondsToSelector:]: message sent to deallocated instance 0x8f58e00 and the debugger shows 0 ___forwarding___ 1 __forwarding_prep_0__ 2 -[CATiledLayer(CATiledLayerPrivate) canDrawRect:levelOfDetail:] 3 tiled_layer_render 4 CAImageProviderThread 5 CAImageProviderBackgroundThread 6 CA::DispatchGroup::thread 7 thread_fun 8

how to traverse window/view hierarchy of other application in OS X?

时光总嘲笑我的痴心妄想 提交于 2019-12-07 11:54:11
问题 I am trying to figure out how to get(read only) entire window/view hierarchy of any application. I get list of all open windows using "CGWindowListCopyWindowInfo" . It also returns window number( "kCGWindowNumber" ). It also shows sharing status of root window by "kCGWindowSharingState = 1;" . Now, I want to check that a particular window/view present in hierarchy of that application. I got kCGWindowNumber which is root window of application. 回答1: This is now possible via the View Debugging