Questions tagged [cgbitmapcontextcreate]

Creates a bitmap graphics context (drawing destination) in Apple's Core Graphics framework.

The Core Graphics framework is often referred to as "CG"

See Apple's CGBitmap reference for more specific information, or The Graphics Contexts section of Apple's Quartz 2D Programming Guide for background information.

67 questions
3
votes
2 answers

CGBitmapContextCreate memory leak?

I'm not sure I understand how to free a bitmap context. I'm doing the following: CGContextRef context = CGBitmapContextCreate(nil, size.width, size.height, 8, 0, CGColorSpaceCreateDeviceRGB(), kCGBitmapAlphaInfoMask); . . // (All straightforward…
Amiram Stark
  • 2,208
  • 22
  • 32
3
votes
1 answer

Convert an image to a 16bit color image

I'm looking for a way to optimize my images by converting its color from 32bit to 16bit rather than just solely resize it. So this is what I'm doing: - (UIImage *)optimizeImage:(UIImage *)image { float newWidth = image.size.width; float…
huong
  • 4,534
  • 6
  • 33
  • 54
3
votes
3 answers

Why is CGBitmapContextCreateImage slower than [UIImage initWithData:]?

I'm currently working on an application which displays many images one after another. I don't have the luxury of using video for this unfortunately, however, I can choose the image codec in use. The data is sent from a server to the application,…
Dale Myers
  • 2,703
  • 3
  • 26
  • 48
3
votes
1 answer

Drawing UIImage using CGBitmapContextCreate - Full Size Image for Texture - iOS

I am using the below code to draw a UIImage. I am using some vertices to draw, in this case, a square : - (UIImage *)drawTexture : (NSArray *)verticesPassed { CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef con…
GuybrushThreepwood
  • 5,598
  • 9
  • 55
  • 113
3
votes
1 answer

Wrong CGImageGetBytesPerRow value for vImageBoxConvolve_ARGB8888 usage

At start I need to do a fast real-time image blur. Found a useful tutorial Perform a blur using vImage. Here is the code sample -(UIImage *)boxblurImage:(UIImage *)image boxSize:(int)boxSize { CGImageRef img = image.CGImage; vImage_Buffer…
Skifcha
  • 31
  • 5
3
votes
2 answers

In Core Graphics, why is Alpha channel preferred to be most significant? (kCGImageAlphaPremultipliedFirst vs kCGImageAlphaPremultipliedLast)

Most code that creates a bitmap context uses kCGImageAlphaPremultipliedFirst, to create ARGB, instead of kCGImageAlphaPremultipliedLast to create RGBA. Is there a reason ARGB is preferred? (the usage): CGBitmapContextCreate(NULL, size.width,…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
2
votes
0 answers

CGBitmapContext byte order changed to ABGR - and CGImage metadata doesn't seem to match bitmap contents

I am standardizing the orientation and max size of an image using the following code (gleaned from elsewhere): + (UIImage *)scaleAndRotateImage:(UIImage *)image { int kMaxResolution = 960; // Or whatever CGImageRef imgRef = image.CGImage; …
Spanner
  • 312
  • 3
  • 11
2
votes
1 answer

Alpha Detection in Layer OK on Simulator, not iPhone

First, check out this very handy extension to CALayer from elsewhere on SO. It helps you determine if a point in a layer's contents-assigned CGImageRef is or isn't transparent. n.b.: There is no guarantee about a layer's contents being representable…
2
votes
0 answers

error in CGBitmapContextCreate

i'm trying to create UIImage from the sampleBufferData and here what i have in the console : CGBitmapContextCreate: invalid data bytes/row: should be at least 1920 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst. :…
2
votes
1 answer

resize image with aspect ratio

I try to resize image with aspect ratio, like done in the following links Resizing UIimages pulled from the Camera also ROTATES the UIimage? https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more This works fine…
ErikS
  • 31
  • 1
  • 5
2
votes
3 answers

Help please with CGBitmapContext and 16 bit images

I'd LOVE to know what I'm doing wrong here. I'm a bit of a newbie with CGImageRefs so any advice would help. I'm trying to create a bitmap image that has as it's pixel values a weighted sum of the pixels from another bitmap, and both bitmaps are…
Kevin Gross
  • 121
  • 1
  • 7
2
votes
1 answer

how to change color of part of UIImage?

I have one image which is in grayscale and I am applying it's original color in some part of that image and I have achieved it. Now I want to change color of that part in which I have applied original color in image I have this: Original Image I…
2
votes
1 answer

Error With CBitmapContextCreate, CGContextDrawImage, CGBitmapContextCreateImage

Error: CGBitmapContextCreate: invalid data bytes/row: should be at least 400 for 8 integer bits/component, 3 components, kCGImageAlphaNoneSkipFirst. Error: CGContextDrawImage: invalid context Error: CGBitmapContextCreateImage: invalid…
wsidell
  • 712
  • 7
  • 14
2
votes
1 answer

CGBitmapContextCreate gives EXC_BAD_ACCESS in iPhone 6+

When calling CGBitmapContextCreate method the app crashes giving EXC_BAD_ACCESS. This happens only in iPhone 6+ (when running on on device). CGContextRef context = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace,…
Gokul
  • 1,236
  • 1
  • 14
  • 26
2
votes
0 answers

Objective C: CGBitmapContextCreate, pixel by pixel processing

First of all sorry for my english. I'm doing paint iOS application. I was decided to use pixel by pixel processing of image. It is needed to create difficult "brush" tools. I was use this algorithm. My code: ViewController.h #import…
MavrinPN
  • 21
  • 1
  • 3