CGImage represents a drawable image object in Core Graphics (the low-level procedural drawing API for iOS and Mac OS X).
Questions tagged [cgimage]
563 questions
5
votes
2 answers
Trim UIImage border
Here's an example of an image I would like to trim. I want to get rid of the borders around the image (in this case the top and bottom black bars).
I found a library on Github: CKImageAdditions, however it doesn't seem to work. When I pass in a…

runmad
- 14,846
- 9
- 99
- 140
5
votes
2 answers
Converting NSData to CGImage and then back to NSData makes the file too big
I have built a camera using AVFoundation.
Once my AVCaptureStillImageOutput has completed its captureStillImageAsynchronouslyFromConnection:completionHandler: method, I create a NSData object like this:
NSData *imageData =…

Will
- 1,697
- 17
- 34
5
votes
7 answers
takepicture() vs UIGetScreenImage()
I'm trying to build a QRCodeReader for a project our research group is working on for the iPhone. After much research I found the program called QuickMark. This program scans automatically for QRCodes. What it appears to do is load the UIImagePicker…

Oni
- 652
- 2
- 9
- 22
5
votes
8 answers
iPhone - UIImage Leak, CGBitmapContextCreateImage Leak
Alright I am having a world of difficulty tracking down this memory leak. When running this script I do not see any memory leaking, but my objectalloc is climbing. Instruments points to CGBitmapContextCreateImage > create_bitmap_data_provider >…

bbullis21
- 741
- 3
- 9
- 21
5
votes
1 answer
The joys of realtime gif decoding
I have written this gist to convert gif data downloaded from the this incredible site and turn that into a mp4 that is playable with MPMoviePlayerController.
The problem is, I must download the entire gif and then start converting. I would like to…

Paul de Lange
- 10,613
- 10
- 41
- 56
5
votes
1 answer
Converting UIImage to CGImage cause rotation of Image
I am trying to crop image by my custom cropper. Not from the UIImagePickerController's. Now for that I am showing the Image captured from Image Picker in a UIImgeView by handling UIImagePicker's delegate:
-…

Kapil Choubisa
- 5,152
- 9
- 65
- 100
4
votes
2 answers
Converting from UIImage/CGImage to Leptonica Pix structure
I want to use Leptonica library in my iOS application for image processing and have troubles figuring out how to get Leptonica's Pix structure from UIImage. What I suggest to do is something like the following:
UIImage *image = [UIImage…

mym
- 252
- 2
- 9
4
votes
1 answer
iOS How to perform rotation on a cgimage efficiently (up to 125 frames)?
I have two images, let's call them image A and image B. I'm trying to rotate and scale image A and to draw it on top of image B at specific location.
I use the function and method below to :
1. rotate and scale my image
2. Draw Image A into Image B…

Pierre Addoum
- 41
- 6
4
votes
2 answers
CGImageCreateWithMaskingColors leaving border when removing color
I'm using the code below to make the color magenta transparent:
UIImage *inputImage = [UIImage imageWithData:UIImageJPEGRepresentation(anchorWithMask, 1.0)];
const float colorMasking[6] = {0.0, 255.0, 0.0, 2.0, 0.0, 255.0};
CGImageRef imageRef =…

MB.
- 4,167
- 8
- 52
- 79
4
votes
6 answers
Solution Like Trash Can Animation
I would like to put the undocumented trash can animation in my program. The call
method is:
+ (void)animateToolbarItemIndex:(unsigned)index duration:(double)duration target:(id)target didFinishSelector:(SEL)selector;
Can anyone figure out what I…

T.J.
- 3,942
- 2
- 32
- 40
4
votes
3 answers
New CALayer.contents does not display until view is resized
I have a CALayer that needs to display frames of video. Every time a frame is rendered (as a CGImageRef), this method is called:
- (void)displayFrame:(CGImageRef)frame {
[view layer].contents = (id)frame;
}
What's strange is that this, at…

spudwaffle
- 2,905
- 1
- 22
- 29
4
votes
1 answer
setColor on NSBitmapImageRep not working in Swift
I'm trying to figure out how setColor works. I have the following code:
lazy var imageView:NSImageView = {
let imageView = NSImageView(frame: view.frame)
return imageView
}()
override func viewDidLoad() {
…

Ben A.
- 874
- 7
- 23
4
votes
0 answers
How can I change this black shade (gradient) to some colored shade?
I want to use the actual color of the image, apply alpha effect pixel by pixel and create something like this but in colored way. How can I do it?
I tried giving it a color but it turned my image from white to pink.
In this code, I go pixel by pixel…

Saad Tahir
- 325
- 2
- 13
4
votes
1 answer
Check if subsection of UIImage is light or dark
I'm attempting to overlay a chevron button that will allow the user to dismiss the current view. The colour of the chevron should be light on dark images, and dark on light images. I've attached a screenshot of what I'm describing.
However, there…

Avery Vine
- 154
- 10
4
votes
0 answers
generateCGImagesAsynchronously produces duplicate images according to actualTime
I am able to get the frames from a video using AVAssetImageGenerator, and I do so using generateCGImagesAsynchronously. Whenever the result succeeds, I print the requestedTime in seconds as well as the actualTime for that image. In the end, however,…

bruteforce
- 83
- 7