Questions tagged [cgcontext]

The CGContextRef opaque type represents a Quartz 2D drawing destination.

977 questions
12
votes
2 answers

How to merge UIImages while using transform (scale, rotation and translation)?

I'm trying to replicate a function of Instagram where you have your picture and you can add stickers (others images) and then save it. So on the UIImageView that holds my picture, I add the sticker (another UIImageView) to it as a subview,…
Nico
  • 6,269
  • 9
  • 45
  • 85
12
votes
2 answers

UIMarkupTextPrintFormatter PDF creation with custom background and transparent HTML content

I am using a UIPrintPageRenderer together with a UIMarkupTextPrintFormatter to print an html page which is rendered in a UIWebView. I am trying to achieve the following: I want to render the html content as a transparent layer onto the context but…
christopher.online
  • 2,614
  • 3
  • 28
  • 52
12
votes
4 answers

CGContext line drawing: CGContextFillPath not working?

Anyone have any idea why CGContextFillPath won't work in the code snippet below? I'm using the following code to draw to a UIImageView. It's stroking the path correctly, but ignoring…
RyJ
  • 3,995
  • 6
  • 34
  • 54
12
votes
4 answers

iPhone CGContext: drawing two lines with two different colors

I am having some troubles using the CGContext with an iPhone app. I am trying to draw several lines with different colors, but all the lines always end up having the color which was used last. I tried several approaches, but haven't been lucky. I…
phonecoddy
  • 254
  • 1
  • 3
  • 6
12
votes
3 answers

CGContext: how do I erase pixels (e.g. kCGBlendModeClear) outside of a bitmap context?

I'm trying to build an eraser tool using Core Graphics, and I'm finding it incredibly difficult to make a performant eraser - it all comes down to: CGContextSetBlendMode(context, kCGBlendModeClear) If you google around for how to "erase" with Core…
Rob
  • 25,984
  • 32
  • 109
  • 155
12
votes
3 answers

Erasing on UIImageView

How can I erase content on front UIImage by swiping finger on it and display UIImage that is back side of UIView. I had used following code in - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event to erase front…
Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94
12
votes
3 answers

Saving and restoring CGContext

I'm trying to save and restore a CGContext to avoid doing heavy drawing computations for a second time and I'm getting the error : CGGStackRestore: gstack underflow. What am I doing wrong? What is the correct way to do this? -…
cocoatoucher
  • 1,483
  • 3
  • 17
  • 22
11
votes
4 answers

drawRect drawing 'transparent' text?

I am looking to draw a UILabel (preferable through subclassing) as a transparent label, but with solid background. I draw up an quick example (sorry, it's ugly, but it gets the points across :)). Basically I have a UILabel and I would like the…
runmad
  • 14,846
  • 9
  • 99
  • 140
11
votes
1 answer

Core Graphics Rotating a Path

This should be a simple one, basically I have a few paths drawn with core graphics, and I want to be able to rotate them (for convenience). I've tried using CGContextRotateCTM(context); but it's not rotating anything. Am I missing something? Here's…
Scott Langendyk
  • 311
  • 5
  • 14
11
votes
1 answer

Polygon overlays interfering with each other when filling a MKPolygon with a CGPattern (using Quartz 2D)

Background In iOS6, I used to add several MKPolygon (overlays) on the MKMapView and to provide a specific MKOverlayView to the mapView:viewForOverlay: callback (see MKMapViewDelegate Class Reference). This specific view's job was to fill the…
Thibault D.
  • 10,041
  • 3
  • 25
  • 56
11
votes
4 answers

Invalid context when creating UIImageView

I have an error when I tried to create a UIImageView. Look at this code : UIImage* backgroundPanel = [[UIImage imageNamed:@"loginPanelBackground.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(90, 0, 149, 416)]; self.connexionBackgroundImgView =…
seb
  • 401
  • 1
  • 4
  • 12
10
votes
2 answers

Copy CGContext into another CGContext

I am performing some CG drawing operations into a CGContext that I created for an MKMapOverlayView. After drawing into my context, I create an image and paste it into the context that MapKit provided. - (void)drawMapRect:(MKMapRect)mapRect…
Tim Reddy
  • 4,340
  • 1
  • 40
  • 77
10
votes
1 answer

Drawing dashed and continuous lines

I need to draw lines; some are dashed and others are continuous. I cannot know which are dashed and which are not. When I draw the dashed lines, I use this: CGContextSetLineDash(context, 5, linedashPattern, 2); // set dashed line It happens,…
Safari
  • 11,437
  • 24
  • 91
  • 191
10
votes
3 answers

Erasing after drawing with CGContext

I'm trying to do a simple drawing app for the iPad where you can draw on a picture, and I'm using CGContext stuff to do it but the way I originally planned on handling erasing was to just draw over stuff with white...except I just realized today…
Lindsey
  • 235
  • 3
  • 11
10
votes
5 answers

iPhone CGContextRef CGBitmapContextCreate unsupported parameter combination

In my application I need to resize and crop some images, stored locally and online. I am using Trevor Harmon's tutorial which implements UIImage+Resize. On my iPhone 4(iOS 4.3.1) everything works OK, I have no problems. But on my iPhone 3G (iOS 3.2)…
Andrei Neacsu
  • 1,453
  • 3
  • 20
  • 33
1 2
3
65 66