core-graphics

Drawing on the retina display using CoreGraphics - Image pixelated

ⅰ亾dé卋堺 提交于 2019-12-05 02:17:04
In my iOS application, I am trying to draw curves using CoreGraphics. The drawing itself works fine, but on the retina display the image gets drawn using the same resolution, and does not get pixel doubled. The result is a pixelated image. I am drawing using the following functions: - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.canvasView]; UIGraphicsBeginImageContext(self.canvasView.frame.size); [canvasView.image drawInRect:self.canvasView.frame]; CGContextRef ctx =

How to get a CGImageRef from Context-Drawn Images?

醉酒当歌 提交于 2019-12-05 02:11:39
Ok using coregraphics, I'm building up an image which will later be used in a CGContextClipToMask operation. It looks something like the following: UIImage *eyes = [UIImage imageNamed:@"eyes"]; UIImage *mouth = [UIImage imageNamed:@"mouth"]; UIGraphicsBeginImageContext(CGSizeMake(150, 150)); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(context, 0, 0, 0, 1); CGContextFillRect(context, bounds); [eyes drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1]; [mouth drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1]; // how can i now get a CGImageRef here

ios - Drawing Brush from finger toches moves

女生的网名这么多〃 提交于 2019-12-05 01:23:34
问题 i want to draw in my iPad app as in the following image in my app i have placed a image and while moving the finger(touch movement) i am repeating the images, but my image seems to be as follows. Following is my code to draw the image CGBlendMode blendMode = kCGBlendModeColorDodge; UIGraphicsBeginImageContext(drawImage.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(),

From CATransform3D to CGAffineTransform

不羁岁月 提交于 2019-12-05 00:53:31
问题 I'm using the following function to apply a pulse effect to a view - (void)pulse { CATransform3D trasform = CATransform3DScale(self.layer.transform, 1.15, 1.15, 1); trasform = CATransform3DRotate(trasform, angle, 0, 0, 0); CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; animation.toValue = [NSValue valueWithCATransform3D:trasform]; animation.autoreverses = YES; animation.duration = 0.3; animation.timingFunction = [CAMediaTimingFunction functionWithName

iPhone Performance Differences in Quartz Drawing vs. Pre-Baked Images (which I guess simplifies to Quartz vs. Quartz)

≡放荡痞女 提交于 2019-12-05 00:53:04
问题 New to Quartz and I am curious on the drawing speeds of simple shapes, gradients, and shadows; specifically comparing Quartz drawing functions to Quartz image drawing on the iPhone. Say that I need to draw a filled, stroked, and shadowed rectangle. I'm assuming that importing a pre-baked rect as a PNG and drawing it using drawInRect: or drawAtPoint: is faster than using Quartz's drawing functions to draw the same thing, since the latter requires explicit calculations. On the other hand,

Build a UIImage with multiple stretchable images

拟墨画扇 提交于 2019-12-05 00:50:36
问题 I have 3 images, a left cap, right cap, and center. Perhaps using CGImageRefs (?), is there a way to build a bitmap based on a CGRect that would center the center piece in some container, stretch the left cap until it reaches the center piece and the same for the right then produce a UIImage ? 回答1: Ok I looked it up as promised. Here is a solution: The Basic Idea take the left cap and make an UIImage with stretched right side "glue" it with the arrow UIImage and now glue it with right cap

What is different between CoreGraphics and CoreAnimation?

江枫思渺然 提交于 2019-12-05 00:13:20
问题 I am developing iphone game using coregraphics. but the speed is very slow. I could not play my game.. So, I googled a lot.. During the googling, I found the belows. CoreGraphics, CoreAnimation, OpenGL ES, CALayer, Quartz 2D I am so confused between them. Someone told me coregraphics is not using GPU. Some told me it is using GPU. coregraphics is best or openGL is best, calayer is better. ^^;;;; What is different between them and which one is using GPU?? Which one is the best to make a game.

Keeping the y-axis fixed at place?

本小妞迷上赌 提交于 2019-12-04 20:46:57
this is the code in the continuation of this question.... Allow horizontal scrolling only in the core-plot barchart? -(BOOL)pointingDeviceDraggedAtPoint:(CGPoint)interactionPoint { if ( !self.allowsUserInteraction || !self.graph.plotArea ) { return NO; } CGPoint pointInPlotArea = [self.graph.plotArea convertPoint:interactionPoint toLayer:self.graph.plotArea]; if ( isDragging ) { pointInPlotArea.y = lastDragPoint.y;//-- Madhup Changed it for allwoing scrolling only in horizontal direction --// //-- Madhup Changed it for allwoing scrolling only in horizontal direction --// //CGPoint displacement

Memory consumption spikes when resizing, rotating and cropping images on iPhone

[亡魂溺海] 提交于 2019-12-04 20:27:12
I have an "ImageManipulator" class that performs some cropping, resizing and rotating of camera images on the iPhone. At the moment, everything works as expected but I keep getting a few huge spikes in memory consumption which occasionally cause the app to crash. I have managed to isolate the problem to a part of the code where I check for the current image orientation property and rotate it accordingly to UIImageOrientationUp . I then get the image from the bitmap context and save it to disk. This is currently what I am doing: CGAffineTransform transform = CGAffineTransformIdentity; // Check

convert an opencv affine matrix to CGAffineTransform

雨燕双飞 提交于 2019-12-04 20:23:04
I'd like to take an affine matrix that I have from OpenCV: Mat T = getAffineTransform(src_pt, dst_pt); and then convert it into a CGAffineTransform for use in Core Graphics/Objective-C/iOS. ( CGAffineTransform docs ) I've tried: CGAffineTransform t = CGAffineTransformIdentity; t.a = T.at<float>(0,0); t.b = T.at<float>(0,1); t.c = T.at<float>(1,0); t.d = T.at<float>(1,1); t.tx = T.at<float>(0,2); t.ty = T.at<float>(1,2); This works fine for x and y translations, but NOT if there is any rotation in the matrix. Something seems to be missing since the resulting image seems to be skewed strangely.