¡@

Home 

2014/10/15 ¤U¤È 10:04:48

iphone Programming Glossary: bytesperrow

Retrieving a pixel alpha value for a UIImage

http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage

colorSpace CGColorSpaceCreateDeviceRGB rawData malloc height width 4 bytesPerPixel 4 bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData.. 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage.. array index for the given alpha channel using the coordinates from the UIImageView. int byteIndex bytesPerRow uiViewPoint.y uiViewPoint.x bytesPerPixel unsigned char alpha rawData byteIndex 3 However I don't get..

Convert image to grayscale

http://stackoverflow.com/questions/1298867/convert-image-to-grayscale

CGImage NSUInteger width CGImageGetWidth image NSUInteger height CGImageGetHeight image NSUInteger bytesPerRow bytesPerPixel width CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB unsigned char rawData malloc.. height width 4 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage.. height pImage.size.height DebugLog @ width d width DebugLog @ height d height NSUInteger bytesPerRow bytesPerPixel width for int xCoordinate 0 xCoordinate width xCoordinate for int yCoordinate 0 yCoordinate..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

#define RGBA 4 #define RGBA_8_BIT 8 In my UIImage subclass I declared instance variables size_t bytesPerRow size_t byteCount size_t pixelCount CGContextRef context CGColorSpaceRef colorSpace UInt8 pixelByteData.. bits each of red green blue and alpha. self setBytesPerRow self.size.width RGBA self setByteCount bytesPerRow self.size.height self setPixelCount self.size.width self.size.height Create RGB color space self setColorSpace.. CGBitmapContextCreate void pixelData self.size.width self.size.height RGBA_8_BIT bytesPerRow colorSpace kCGImageAlphaPremultipliedLast Make sure we have our context if context free pixelData..

Retrieving a pixel alpha value for a UIImage

http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage

image NSUInteger height CGImageGetHeight image CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB rawData malloc height width 4 bytesPerPixel 4 bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast.. bytesPerPixel 4 bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake 0 0 width height image CGContextRelease.. height image CGContextRelease context I then calculate the array index for the given alpha channel using the coordinates from the UIImageView. int byteIndex bytesPerRow uiViewPoint.y uiViewPoint.x bytesPerPixel unsigned char alpha rawData byteIndex 3 However I don't get the values I expect. For a completely black transparent area..

Convert image to grayscale

http://stackoverflow.com/questions/1298867/convert-image-to-grayscale

getBytesForImage UIImage pImage CGImageRef image pImage CGImage NSUInteger width CGImageGetWidth image NSUInteger height CGImageGetHeight image NSUInteger bytesPerRow bytesPerPixel width CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width 4 CGContextRef context CGBitmapContextCreate.. CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width 4 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake 0 0 width height image CGContextRelease.. getBytesForImage pImage NSUInteger width pImage.size.width NSUInteger height pImage.size.height DebugLog @ width d width DebugLog @ height d height NSUInteger bytesPerRow bytesPerPixel width for int xCoordinate 0 xCoordinate width xCoordinate for int yCoordinate 0 yCoordinate height yCoordinate int byteIndex bytesPerRow yCoordinate..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

data . Method 1 Writable Pixel Information I defined constants #define RGBA 4 #define RGBA_8_BIT 8 In my UIImage subclass I declared instance variables size_t bytesPerRow size_t byteCount size_t pixelCount CGContextRef context CGColorSpaceRef colorSpace UInt8 pixelByteData A pointer to an array of RGBA bytes in memory RPVW_RGBAPixel.. bitmap NSLog @ Returning bitmap representation of UIImage. 8 bits each of red green blue and alpha. self setBytesPerRow self.size.width RGBA self setByteCount bytesPerRow self.size.height self setPixelCount self.size.width self.size.height Create RGB color space self setColorSpace CGColorSpaceCreateDeviceRGB if colorSpace NSLog.. the format specified here by CGBitmapContextCreate. self setContext CGBitmapContextCreate void pixelData self.size.width self.size.height RGBA_8_BIT bytesPerRow colorSpace kCGImageAlphaPremultipliedLast Make sure we have our context if context free pixelData NSLog @ Context not created Draw the image to the bitmap..

Retrieving a pixel alpha value for a UIImage

http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage

image CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB rawData malloc height width 4 bytesPerPixel 4 bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent.. width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context.. I then calculate the array index for the given alpha channel using the coordinates from the UIImageView. int byteIndex bytesPerRow uiViewPoint.y uiViewPoint.x bytesPerPixel unsigned char alpha rawData byteIndex 3 However I don't get the values I expect...

Convert image to grayscale

http://stackoverflow.com/questions/1298867/convert-image-to-grayscale

image pImage CGImage NSUInteger width CGImageGetWidth image NSUInteger height CGImageGetHeight image NSUInteger bytesPerRow bytesPerPixel width CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width 4 CGContextRef.. char rawData malloc height width 4 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context.. pImage.size.width NSUInteger height pImage.size.height DebugLog @ width d width DebugLog @ height d height NSUInteger bytesPerRow bytesPerPixel width for int xCoordinate 0 xCoordinate width xCoordinate for int yCoordinate 0 yCoordinate height yCoordinate..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

I defined constants #define RGBA 4 #define RGBA_8_BIT 8 In my UIImage subclass I declared instance variables size_t bytesPerRow size_t byteCount size_t pixelCount CGContextRef context CGColorSpaceRef colorSpace UInt8 pixelByteData A pointer to an array.. of UIImage. 8 bits each of red green blue and alpha. self setBytesPerRow self.size.width RGBA self setByteCount bytesPerRow self.size.height self setPixelCount self.size.width self.size.height Create RGB color space self setColorSpace CGColorSpaceCreateDeviceRGB.. self setContext CGBitmapContextCreate void pixelData self.size.width self.size.height RGBA_8_BIT bytesPerRow colorSpace kCGImageAlphaPremultipliedLast Make sure we have our context if context free pixelData NSLog @ Context..

How do I create/render a UIImage from a 3D transformed UIImageView?

http://stackoverflow.com/questions/1949003/how-do-i-create-render-a-uiimage-from-a-3d-transformed-uiimageview

inputData malloc height width 4 unsigned char outputData malloc height width 4 NSUInteger bytesPerPixel 4 NSUInteger bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate inputData width height bitsPerComponent.. NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate inputData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context.. height imageRef CGContextRelease context context CGBitmapContextCreate outputData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context..

layer.renderInContext doesn't take layer.mask into account?

http://stackoverflow.com/questions/4896296/layer-renderincontext-doesnt-take-layer-mask-into-account

size_t cWidth CGImageGetWidth image size_t cHeight CGImageGetHeight image size_t bitsPerComponent 8 size_t bytesPerRow 4 cWidth Now we build a Context with those dimensions. CGContextRef context CGBitmapContextCreate nil cWidth cHeight bitsPerComponent.. build a Context with those dimensions. CGContextRef context CGBitmapContextCreate nil cWidth cHeight bitsPerComponent bytesPerRow CGColorSpaceCreateDeviceRGB CGImageGetBitmapInfo image The location where you draw your image on the context is not always..

iOS CVImageBuffer distorted from AVCaptureSessionDataOutput with AVCaptureSessionPresetPhoto

http://stackoverflow.com/questions/6540710/ios-cvimagebuffer-distorted-from-avcapturesessiondataoutput-with-avcapturesessio

CGContextRef context CGBitmapContextCreate CVPixelBufferGetBaseAddress cameraFrame bufferWidth bufferHeight 8 bytesPerRow colorSpace kCGBitmapByteOrder32Little kCGImageAlphaPremultipliedFirst CGImageRef cgImage CGBitmapContextCreateImage context.. out the padding is 48 as you can see from the debugger gdb po pixelBuffer CVPixelBuffer 0x2934d0 width 852 height 640 bytesPerRow 3456 pixelFormat BGRA # 3456 852 4 48 OpenGL can compensate for this but OpenGL ES cannot more info here openGL SubTexturing.. int frameWidth CVPixelBufferGetWidth pixelBuffer int frameHeight CVPixelBufferGetHeight pixelBuffer size_t bytesPerRow extraBytes bytesPerRow CVPixelBufferGetBytesPerRow pixelBuffer extraBytes bytesPerRow frameWidth 4 GLubyte pixelBufferAddr..

iPhone Watermark on recorded Video.

http://stackoverflow.com/questions/7205820/iphone-watermark-on-recorded-video

uint8_t baseAddress uint8_t CVPixelBufferGetBaseAddressOfPlane imageBuffer 0 Get information of the image size_t bytesPerRow CVPixelBufferGetBytesPerRow imageBuffer size_t width CVPixelBufferGetWidth imageBuffer size_t height CVPixelBufferGetHeight.. colorSpace CGColorSpaceCreateDeviceRGB CGContextRef newContext CGBitmapContextCreate baseAddress width height 8 bytesPerRow colorSpace kCGBitmapByteOrder32Little kCGImageAlphaPremultipliedFirst CGImageRef newImage CGBitmapContextCreateImage newContext..