core-graphics

CGImageCreateWithImageInRect not Cropping Correctly

馋奶兔 提交于 2019-12-30 10:07:11
问题 I'm having a hell of a time using CGImageCreateWithImageInRect to crop a photo. My app has the user move / enlarge an image till it fills a 316 x 316 view, then I want it to crop off any area outside the box and save the image as a UIImage. I determine the crop origin by taking the absolute value of the x and y imageview origin as that brings me back to 0,0 of the view / box that contains the imageview. Below is the code: CGRect croppedRect = CGRectMake(fabs(widthDistanceToOrigin), fabs

Drawing in UIView on touch points gives blurr drawing effect on boundaries

拟墨画扇 提交于 2019-12-30 08:38:07
问题 To sort out my last problem : Draw/Paint like sketch color inside a bezier path in UIView, I took an exact Image (of path) filled with selected color. Then, to draw that in UIView , for context color I took: lineColor=[UIColor colorWithPatternImage:img]; in drawrect : CGPoint mid1 = midPoint(previousPoint1, previousPoint2); CGPoint mid2 = midPoint(currentPoint, previousPoint1); [curImage drawInRect:CGRectZero]; CGContextRef context = UIGraphicsGetCurrentContext(); [self.layer renderInContext

How to draw a text using CoreGrahpics & Core animation

只愿长相守 提交于 2019-12-30 05:27:25
问题 I want to achieve this type of animation.please check this URL https://www.dropbox.com/s/gz9vfy5refsh7a5/Screen.mov?dl=0 I am adding Code which I have used in the project where I have used Core Graphics to render the text with animation but I am not able to animate text which is being shown in the mentioned link This is code which i am using to render the text on the screen let context = UIGraphicsGetCurrentContext()! context.saveGState() context.setAlpha(noLightText) let nOLIGHTRect = CGRect

iOS: CAShape Layer Path Transformation

非 Y 不嫁゛ 提交于 2019-12-30 05:25:25
问题 I have used CAShape Layer before doing basic transformation on paths - from a smaller circle into a larger circle. Good enough, but then I tried to transform a triangle into a circle; it worked, but the transformation is weird. Other words, from one shape to another, it "flips", "twists" before the final shape is formed. With the same shapes, there is no problem - from a circle to a circle - but with different shapes, the transformation is weird. I wonder if this is the expected way? Or is

Mac OS X: Drawing into an offscreen NSGraphicsContext using CGContextRef C functions has no effect. Why?

烂漫一生 提交于 2019-12-30 01:26:25
问题 Mac OS X 10.7.4 I am drawing into an offscreen graphics context created via +[NSGraphicsContext graphicsContextWithBitmapImageRep:] . When I draw into this graphics context using the NSBezierPath class , everything works as expected. However, when I draw into this graphics context using the CGContextRef C functions , I see no results of my drawing. Nothing works. For reasons I won't get into, I really need to draw using the CGContextRef functions (rather than the Cocoa NSBezierPath class). My

CGContext pdf page aspect fit

穿精又带淫゛_ 提交于 2019-12-30 00:42:06
问题 I am displaying a pdf page on the CGContext using the code - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context { CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0); CGContextFillRect(ctx, layer.bounds); CGContextTranslateCTM(ctx, 0.0, layer.bounds.size.height); CGContextScaleCTM(ctx, 1.0, -1.0); CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(myPageRef, kCGPDFBleedBox, layer.bounds, 0, true)); CGContextDrawPDFPage(ctx, myPageRef); } The problem is that the pdf page is

How to directly update pixels - with CGImage and direct CGDataProvider

笑着哭i 提交于 2019-12-29 15:00:23
问题 Actual Question Several answers will solve my problem: Can I force a CGImage to reload its data from a direct data provider (created with CGDataProviderCreateDirect ) like CGContextDrawImage does? Or is there some other way I can get setting to self.layer.contents to do it? Is there a CGContext configuration, or trick I can use to render 1024x768 images at least 30 fps consistently with CGContextDrawImage . Has anyone been able to successfully use CVOpenGLESTextureCacheCreateTextureFromImage

How to directly update pixels - with CGImage and direct CGDataProvider

佐手、 提交于 2019-12-29 14:58:49
问题 Actual Question Several answers will solve my problem: Can I force a CGImage to reload its data from a direct data provider (created with CGDataProviderCreateDirect ) like CGContextDrawImage does? Or is there some other way I can get setting to self.layer.contents to do it? Is there a CGContext configuration, or trick I can use to render 1024x768 images at least 30 fps consistently with CGContextDrawImage . Has anyone been able to successfully use CVOpenGLESTextureCacheCreateTextureFromImage

Drawing an angle/angular/“Conical”/“Arcing” gradient in Objective-C (IOS) using Core Graphics

无人久伴 提交于 2019-12-29 07:53:09
问题 I'm trying to draw a "conical"/"arcing" gradient (I don't know what would be the correct term for this) (Photoshop calls it an "angle" gradient —your friendly neighborhood stackoverflow editor) using Objective-C (IOS), pretty much exactly like the image shown in the following thread. After days of googling and searching the internet to no avail, I've decided to ask for help here. A little background on what I'm trying to do. My objective is to create a custom UIView, which is circular

CGBitmapContextCreate: unsupported parameter combination. How to pass kCGImageAlphaNoneSkipFirst [duplicate]

对着背影说爱祢 提交于 2019-12-29 07:15:25
问题 This question already has answers here : kCGImageAlphaNone unresolved identifier in swift (2 answers) Closed 4 years ago . I originally wrote this App (GitHub) in Obj-C, but need to convert it to Swift. Upon converting I've been having trouble getting the Context for the Bitmap created. Error Message: Whiteboard[2833] <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 24 bits/pixel; 3-component color space; kCGImageAlphaNone; 1500 bytes/row.