quartz-graphics

iOS setting Progress bar value while images are being processed

喜夏-厌秋 提交于 2019-12-12 19:23:44
问题 I have an app processing a couple of images using Quartz, and i wanted to have a UIProgressView that changes after each actions. (e.g. 0.0 0.2 0.4 0.6 0.8 1.0) The problem is, it seems while my image is being processed the UI is completely locked, and the value only changes after all of the process is done (meaning it just gets to 1.0 without going through the sub-steps), Did any of you ever encounter this ? Pseudo: for(uint i=0;i<5;i++){ // Execute some Quartz based action here, such as

OSX Quartz Event Taps: event types and how to edit events

好久不见. 提交于 2019-12-12 08:53:09
问题 Here's my code: #import <ApplicationServices/ApplicationServices.h> CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) { printf("%u\n", (uint32_t)type); return event; } int main (int argc, const char * argv[]) { CFMachPortRef eventTap; CFRunLoopSourceRef runLoopSource; eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0, kCGEventMaskForAllEvents, myCGEventCallback, NULL); runLoopSource = CFMachPortCreateRunLoopSource

CGContextClip() using an inverted path

旧巷老猫 提交于 2019-12-12 08:49:40
问题 I want to have clipped drawing on my CGContext but I need it just the other way round, i.e. I want to add several rectangles to my clipping path using CGContextAddRect() and the clipping should be done in the way that all the rectangles that I have added to my clipping path stay unaffected by any drawing operations. Normally, it's just the other way round, i.e. drawing functions draw to the rectangles that have been added to the clipping path and leave the areas that haven't been added to the

Activate a window using its Window ID

被刻印的时光 ゝ 提交于 2019-12-12 08:20:02
问题 How would I programmatically activate i.e move-to-front-and-focus a window on macOS (not belonging to my app) given its Window ID . My app would run with user granted Accessibility permissions etc. Surprisingly, none of the functions described on the Quartz Window Services page seem to do that. Am using Swift currently, but am open to using Objective-C, AppleScript or whatever. EDIT: I don't want to bring to front all windows of the parent app - only the specific that matches the window ID.

Draw a circle when clicked using quartz

天大地大妈咪最大 提交于 2019-12-12 06:58:05
问题 I want a circle to be drawn when the user clicks anywhere on the screen. Whats missing/is wrong with this code? - (void)drawRect:(CGRect)rect { if (UITouchPhaseBegan) { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(context, 0, 0, 225, 1); CGContextSetRGBFillColor(context, 0, 0, 255, 1); CGRect rectangle = CGRectMake(50, 50, 500, 500); CGContextStrokeEllipseInRect(context, rectangle); } } 回答1: Your code doesn’t do what you think it does. Have a look at the

CGDisplayCaptureWithOptions (kCGDirectMainDisplay, kCGCaptureNoFill) still fills the screen with black

梦想与她 提交于 2019-12-12 05:38:26
问题 Hi I've recently been moving some of our old quickdraw code to use quartz and I've run into one little snag. According to the docs ("Display Capture Options" @ developer.apple.com) I can pass kCGCaptureNoFill as a parameter to CGDisplayCaptureWithOptions(), to disable filling the screen with black when it is captured. I'm using it like so: CGDisplayErr err = CGDisplayCaptureWithOptions (kCGDirectMainDisplay, kCGCaptureNoFill); if (err == kCGErrorSuccess) { etc... } But the screen is still

How can I combine CGPathCreateCopyByDashingPath() and CGPathCreateCopyByStrokingPath() to stroke a dashed CGPath on OS X?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 03:24:11
问题 Core Graphics has two functions, CGPathCreateCopyByDashingPath() and CGPathCreateCopyByStrokingPath() , that both take a CGPath that you want to stroke and convert it into its equivalent fill. I need to do this so I can, for example, stroke a line with a gradient: call CGPathCreateCopyByStrokingPath() , load the path into the CGContext, call CGContextClip() , and then draw the gradient. However, CGPathCreateCopyByStrokingPath() accepts line stroking parameters like line cap, line join, etc.,

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

Drawing class to allow layer control

只谈情不闲聊 提交于 2019-12-11 16:25:08
问题 I would like to implement a drawing class with the help of Quartz . I want to be able to save parts of what is drawn on separate layers. I want these layers to be retrievable, so I can delete/hide/show layers on command. Can I save multiple CGLayerRef as a NSMutableArray property of my class and then be able to retrieve them? If yes, can you point me to an example. If there are any flaws in the "architecture" above, please point me to alternative solutions that could help me accomplish

Using Quartz to draw every second via NSTimer (iPhone)

跟風遠走 提交于 2019-12-11 13:35:52
问题 I'm relatively new to Objective-C + Quartz and am running into what is probably a very simple issue. I have a custom UIView sub class which I am using to draw simple rectangles via Quartz. However I am trying to hook up an NSTimer so that it draws a new object every second, the below code will draw the first rectangle but will never draw again. The function is being called (the NSLog is run) but nothing is draw. Code: - (void)drawRect:(CGRect)rect { context = UIGraphicsGetCurrentContext();