Questions tagged [cgcontextdrawimage]

CGContextDrawImage is available in OSX and iOS which helps to draws an image into a graphics context. The issues related with drawRect or CGContextDrawImage can be tagged with this tag

CGContextDrawImage draws an image into a graphics context. It can be used by importing Apple's CoreGraphics framework.

There are some use cases (not the majority) for which the CALayer and Core Animation approach will not work. For those cases, CGContextDrawImage could spend a lot of time in decompressing or resampling the images as necessary because the images will not be cached in the layer tree.

For more information:

Example:

Draw your image into a grayscale context

  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
  context = CGBitmapContextCreate(nil, inputWidth, inputHeight,
                     8, 0, colorSpace, (CGBitmapInfo)kCGImageAlphaNone);

  CGContextDrawImage(context, imageRect, [imageWithGhost CGImage]);

  CGImageRef imageRef = CGBitmapContextCreateImage(context);
  UIImage * finalImage = [UIImage imageWithCGImage:imageRef];

Related Stack Overflow Questions:

  1. CGContextDrawImage draws image upside down when passed UIImage.CGImage

  2. CGContextDrawImage is EXTREMELY slow after large UIImage drawn into it

  3. rotate image using CGContextDrawImage

74 questions
0
votes
1 answer

UIImage drawAtPoint after CGContextClip

I use ABUITableViewCell and draw all content manually. Also I use CGContextClip to make rounded corners, all works great, but when I tried to draw another image outside clip rect it hasn't been displayed. When I draw NSString I use…
Vitaly Baev
  • 331
  • 1
  • 3
  • 8
0
votes
1 answer

How to draw a UIImage scaled up with interpolation for a retina display?

I load some images from the web in my app and draw them using UIImage drawImage. I want to keep using the same images for the retina display but smooth them with interpolation. How can we accomplish this? I suppose I'm fine with either saving (in…
Cal
  • 1,625
  • 4
  • 20
  • 30
0
votes
1 answer

how to create curve for lines when handwriting

I'm creating an app, and in one part, I'm trying to implement hand-writing. I've used an imageView to write on, which will be saved and sent to a server as a pdf. I have implemented touch begin, move and end, and using contextAddLineToPoint, I can…
Septronic
  • 1,156
  • 13
  • 32
0
votes
1 answer

How erase a line draw in iphone(CGGraphics)?

I am working on an iPhone application of drawing, user can draw a line and can remove as well so can any body help me how to remove the line or drawing? code for draw - (void)drawRect:(CGRect)rect { float newHeight; float newWidth; if…
Mashhadi
  • 3,004
  • 3
  • 46
  • 80
0
votes
1 answer

CGContext strangeness

I have a little code module that should refer as signature panel so that the user can sign on this panel with his finger. The whole thing runs on the iPad. Now, I managed to do the usual touchesBegan(), touchesMoved(), touchesEnded() carousel to…
Fuggly
  • 905
  • 1
  • 8
  • 18
0
votes
0 answers

How can I remove the topbar and the watermark of embedded YouTube video

I want to remove the topbar and watermark which show in the bottom right corner of the youtube video. I was trying to apply showinfo but it was depreciate. I also tried to set a overlay to hide the topbar and watermark but canvas drawimage is also…
0
votes
0 answers

CGContext strokepath makes edges of stroke blurred

I'm working on a simple freehand drawing app. Below is the sample code, I'm using the UIGesture class to track the scribble, i.e., pencil or finger movement, and then stroking those touch points on the UIImageView let previousLocation =…
0
votes
1 answer

iOS TextView is saved blurry when scaled

I tried save textview as image with not device scale. I implemented a method to save an image by adding an arbitrary textview according to the UI value. Because when I tried save image using drawHierarchy method in up scale, image was…
Lucy Jeong
  • 320
  • 7
  • 21
0
votes
1 answer

swift - can't change UIImage tintColor

I have a pattern PNG image, with black dots on transparent background, and I need to change dot's color at custom colors, for example yellow I'm trying to change tint color before drawing it, but image is still black on transparent let templateImage…
nastassia
  • 807
  • 1
  • 12
  • 31
0
votes
0 answers

Improve CGContextDrawImage performance

I have a custom NSView that has it's own drawRect. I draw a lot of images using CGContextDrawImage into the view. The NsView is in a NSScrollView. The issue I am having is, while scrolling, the drawrect takes too long. the scrolling isn't smooth. I…
Hari
  • 73
  • 1
  • 7
0
votes
1 answer

iOS CGContextDrawImage Empty path clip

I'm developing app which makes video from images and it's working well. Exporting images into video is working well and also insert watermark is working. But when app goes background and returned to app and export video the app crashes. Here's a…
Ioan Moldovan
  • 2,272
  • 2
  • 29
  • 54
0
votes
0 answers

How to get a masked UIImage without bad resolution?

I have an iOS application. I take a picture from my camera and I save this then crop this with a mask. The first image from the camera is saved correctly, but when I apply the mask it is saved with a low resolution and a stretched image. I'm using…
user3745888
  • 6,143
  • 15
  • 48
  • 97
0
votes
1 answer

CGContextFillRects vs CGContextAddLineToPoint (rects vs lines) performance

I have a object that renders a grid of lines (used for a plot object I am working on) that will update frequently and shift all the lines around. If the grid will update at 60 fps would using CGContextFillRects or CGContextAddLineToPoint (rectangles…
0
votes
1 answer

CGContextFillRects: CGRect* not working. Assigned CGRect items do not get saved

I am trying to save an array of CGRect to use with CGContextFillRects but the CGRect variables I assign to my minorPlotLines array don't seem to get saved. By the time the object here draws itself minorPlotLines is empty! Does anyone know what is…
0
votes
1 answer

How to place the `UIColor` on `UIImage` at particular (X,Y) position?

I am trying to place UIColor on particular (X,Y) position of UIImage, But not able to get it, Here, My code looks like below, Below method return me a UIColor from particular (X,Y) position of UIImage - (UIColor *)isWallPixel:(UIImage *)image…
Ankit
  • 1
  • 3