uigraphicscontext

How to undo a line stroke ios

旧城冷巷雨未停 提交于 2019-12-08 09:41:53
问题 Im developing a colouring app, however I cant manage to implement an UNDO button. I am unsure of the approach, I have tried implementing NSUndoManager, but I could not get it to work effectively. My approach is possibly incorrect. Im would greatly appreciate an answer that uses code, based on my example. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { mouseSwiped = NO; UITouch *touch = [touches anyObject]; lastPoint = [touch locationInView:self.view]; } - (void)touchesMoved

Convert UIScrollViewPoint to UIImage + ZOOM + ROTATE

佐手、 提交于 2019-12-08 03:22:04
问题 I need to crop UIImage which is loaded in UIScrollview with some rect of Another UIView which is also in UIScrollView Following is View Hierarchy --> View --> UIScrollView --> viewBase (UIView) --> UIImageView -> (Zoomed & rotated ) --> UIView (Target View)(Movable User can move anywhere in scrollview to crop rect) My Image is Rotated & Zoomed I need to get exact part of image in TargetView I am drawing UIImage with rotation on context following is code CGFloat angleCroppedImageRetreacted =

Issues in generating PDF from uiwebview in objective c

我怕爱的太早我们不能终老 提交于 2019-12-06 16:08:51
问题 I have open pdf file in uiwebview, add image and text in uiwebview subview.Then i tried created pdf file. Below sample i have used to generate pdf file. Multiple page writing in single page. How can i write sample quality and exact size. Please check screen shots and below source UIGraphicsBeginPDFContextToData( pdfData, CGRectZero, nil ); for (int i = 0; i < 10; i++) { CGRect f = [pdfView frame]; [pdfView setFrame: f]; UIGraphicsBeginPDFPage(); CGContextRef currentContext =

Issue capturing selected views as they appear on screen with renderInContext in Swift

╄→尐↘猪︶ㄣ 提交于 2019-12-06 00:19:06
I have three views on my storyboard, viewA , viewB , viewC . I’m trying to screen capture only two views as they appear on screen in their current place, viewB and viewC . The trouble is, when I render them, the resulting image captured shows viewB and viewC in incorrect locations, the position of the views change moving top left (0, 0), see image. How can I correct the code below so that I can capture the views viewB and viewC exactly as they are positioned on the view using the renderInContext implementation below? UIGraphicsBeginImageContextWithOptions(self.view.frame.size, false, 0) self

Clip UIImage to UIBezierPath (not masking)

情到浓时终转凉″ 提交于 2019-12-05 15:45:08
I'm trying to clip a UIImage based on a given UIBezierPath , but the resulting image retains the original shape and size. I want the shape and size to resemble the path, i.e. the visible content of the new image. Take a look at this following example: The following is the code I am using to mask an image given a path: func imageByApplyingClippingBezierPath(_ path: UIBezierPath) -> UIImage { UIGraphicsBeginImageContextWithOptions(CGSize( width: size.width, height: size.height ), false, 0.0) let context = UIGraphicsGetCurrentContext()! context.saveGState() path.addClip() draw(in: CGRect(x: 0, y:

renderInContext taxes App Memory

强颜欢笑 提交于 2019-12-05 14:49:15
I'm running this code on a 2448 X 2448 pixel Image. fullScaleView is also 2448 X 2448 ( fullScreenView Rect:{{0, 0}, {2448, 2448}} ). The App memory jumps from 49.7MB to 240MB down to 172MB after the method is complete. It stays at 172MB. It doesn't seem like the app should still be running at such high a memory footprint after this one renderInContext . Where and how should I force a release? (iOS 7 XCode 5 ARC). UIGraphicsBeginImageContextWithOptions(fullScaleView.bounds.size, fullScaleView.opaque, 1.0); [fullScaleView.layer renderInContext: UIGraphicsGetCurrentContext()]; UIImage *viewImage

Issues in generating PDF from uiwebview in objective c

心不动则不痛 提交于 2019-12-04 20:53:34
I have open pdf file in uiwebview, add image and text in uiwebview subview.Then i tried created pdf file. Below sample i have used to generate pdf file. Multiple page writing in single page. How can i write sample quality and exact size. Please check screen shots and below source UIGraphicsBeginPDFContextToData( pdfData, CGRectZero, nil ); for (int i = 0; i < 10; i++) { CGRect f = [pdfView frame]; [pdfView setFrame: f]; UIGraphicsBeginPDFPage(); CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(currentContext, 72, 72); // Translate for 1" margins [[[pdfView

Issue With drawViewHierarchyInRect: afterScreenUpdates while taking snapshot

坚强是说给别人听的谎言 提交于 2019-12-04 20:49:44
I am facing problem with taking snapshot of UIView along with CAEmitterLayer . Below is the code which I am using for taking snapshot: here editingView is my UIView : UIGraphicsBeginImageContextWithOptions(editingView.bounds.size, NO, 0.0); [editingView drawViewHierarchyInRect:editingView.bounds afterScreenUpdates:YES]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); Please go through the below links for Gif Images Link For For afterScreenUpdates:NO (Gif) in this case I am missing Snapshot data Link For For afterScreenUpdates:YES (Gif) in this case

How to save a layered image using a extension function

纵饮孤独 提交于 2019-12-04 05:51:03
问题 I am using a extension function to save a uiview as a uiimage. The code works to save the uiimage. However what I am trying to do is save a transparent image over the image being saved to the photo gallery. So I am trying to save a layered image using a extension function. Right now only the uiivew is being save and the 2nd layer is not being saved. class ViewController: UIViewController,UINavigationControllerDelegate { @IBAction func press(_ sender: Any) { let jake = drawingView

How can I add a watermark to an image using this code?

一笑奈何 提交于 2019-12-03 15:08:00
问题 I know there are several other ways to do this; I don't want to import anything that I don't need to. If someone can help me with his code, that would be great. Currently, it is only saving the original image without the watermark image. extension UIImage { class func imageWithWatermark(image1: UIImageView, image2: UIImageView) -> UIImage { UIGraphicsBeginImageContextWithOptions(image1.bounds.size, false, 0.0) image2.layer.renderInContext(UIGraphicsGetCurrentContext()!) image1.layer