core-graphics

Draw text and add to a UIImage iOS 5/6

强颜欢笑 提交于 2019-12-29 05:32:04
问题 I have a textbox, where i want the written text to be added to a UIImage. How can i draw NSString to a UIImage? I´ve searched, and found lots of examples, but non of them works. Xcode just gives me lots of errors. Simply put, i want to draw a NSString to a UIimage. The UIImage should be the same size as a predefined UIImageView, and be placed in center. Any ideas? 回答1: i think solution is here..i have used this method in one of my application here lbltext is the object of my label. this

iPhone : How to change color of particular pixel of a UIImage?

旧城冷巷雨未停 提交于 2019-12-28 17:56:27
问题 I have a UIImage, I want to change colour of its particular pixel, say 224 x 200th pixel. How can I do this? Is it even possible to do? Thanks in advance. 回答1: After searching a lot for a complete day I got the exact solution, though I found many but none of them worked. Here is what I have got, it works flawlessly -: // This method creates an image by changing individual pixels of an image. Color of pixel has been taken from an array of colours('avgRGBsOfPixel') -(void)createTexture{ self

eraser not working in iOS drawing

痞子三分冷 提交于 2019-12-28 03:10:07
问题 I am working on a drawing project, where I have an eraser option. The code given below is for when I start my app and draw some lines and the proceed to use the eraser. It works fine and I get the eraser effect. Now the second scenario is where I draw some 10 lines and then click on the "undo button" and undo the whole thing, then I redo the whole thing, and now when I click on the "eraser button" and try to erase some part, but instead, it will clear the whole drawing. This is what I am

to drawRect or not to drawRect (when should one use drawRect/Core Graphics vs subviews/images and why?)

断了今生、忘了曾经 提交于 2019-12-28 01:41:10
问题 To clarify the purpose of this question: I know HOW to create complicated views with both subviews and using drawRect. I'm trying to fully understand the when's and why's to use one over the other. I also understand that it doesn't make sense to optimize that much ahead of time, and do something the more difficult way before doing any profiling. Consider that I'm comfortable with both methods, and now really want a deeper understanding. A lot of my confusion comes from learning how to make

to drawRect or not to drawRect (when should one use drawRect/Core Graphics vs subviews/images and why?)

吃可爱长大的小学妹 提交于 2019-12-28 01:40:11
问题 To clarify the purpose of this question: I know HOW to create complicated views with both subviews and using drawRect. I'm trying to fully understand the when's and why's to use one over the other. I also understand that it doesn't make sense to optimize that much ahead of time, and do something the more difficult way before doing any profiling. Consider that I'm comfortable with both methods, and now really want a deeper understanding. A lot of my confusion comes from learning how to make

invalid context 0x0 under iOS 7.0 and system degradation

时光毁灭记忆、已成空白 提交于 2019-12-27 10:31:52
问题 I've read as many search results I could find on this dreaded problem, unfortunatelly, each one seems to focus on a specific function call. My problem is that I get the same error from multiple functions, which I am guessing are being called back from functions that I use. To make matters worse, the actual code is within a custom private framework which is being imported in another project, and as such, debugging isn't as simple? Can anyone point me to the right direction? I have a feeling I

Create Leptonica PIX struct from UIImage

无人久伴 提交于 2019-12-25 15:50:50
问题 I want to create a PIX data structure from a UIImage. The struct of PIX: struct Pix { l_uint32 w; /* width in pixels */ l_uint32 h; /* height in pixels */ l_uint32 d; /* depth in bits */ l_uint32 wpl; /* 32-bit words/line */ l_uint32 refcount; /* reference count (1 if no clones) */ l_int32 xres; /* image res (ppi) in x direction */ /* (use 0 if unknown) */ l_int32 yres; /* image res (ppi) in y direction */ /* (use 0 if unknown) */ l_int32 informat; /* input file format, IFF_* */ char *text; /

Focusing App with activateWithOptions - only works if non-miniaturized

血红的双手。 提交于 2019-12-25 14:26:06
问题 I am trying to focus all windows of another process, I know the PID of it. When I run the following code: app = [NSRuningApplication runningApplicationWithProcessIdentifier: 400]; [app activateWithOptions: (NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)] All windows that are NOT minimized/miniaturized are shown. HOWEVER if all of the windows are minimized/miniaturized none of the windows are shown. How can I un-minimize all windows on activate? I also tried

Can't pass parameter of type CGColorRef in LLDB

爷,独闯天下 提交于 2019-12-25 14:25:07
问题 I'm extending Facebook’s Chisel to be able to visualize a color from the debugger. I want it to work for UIColor , CIColor , and CGColorRef . The two object-based ones are working fine, but the CGColorRef is giving me trouble. Here is the bug I'm working from, where I've already hashed out a bunch of the stuff from this question. I've boiled the issue down to this test case: If I have some function: + (UIColor *)someColor { UIColor *uiColor = [UIColor redColor]; CGColorRef cgColor = uiColor

Simple drawing with Quartz - Core Graphics

大城市里の小女人 提交于 2019-12-25 06:41:05
问题 I want to draw a rectangle with the top-left corner rounded with 3 sub-spaces in it. Something like this: _______ |_|_____| | | |_______| But for some reason I cannot get the inner two lines drawn. - (void) drawRect:(CGRect)rect{ CGContextRef context = UIGraphicsGetCurrentContext(); float cornerRadius = 25.0; float w = self.bounds.size.width; float h = self.bounds.size.height; CGContextMoveToPoint(context, cornerRadius, 0); CGContextAddQuadCurveToPoint(context, 0, 0, 0, cornerRadius);