¡@

Home 

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

iphone Programming Glossary: bytesperpixel

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.. colorSpace CGColorSpaceCreateDeviceRGB rawData malloc height width 4 bytesPerPixel 4 bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height.. 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..

Convert image to grayscale

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

image to grayscale I am trying to convert an image into grayscale in the following way #define bytesPerPixel 4 #define bitsPerComponent 8 unsigned char getBytesForImage UIImage pImage CGImageRef image pImage CGImage.. width CGImageGetWidth image NSUInteger height CGImageGetHeight image NSUInteger bytesPerRow bytesPerPixel width CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width.. 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..

Retrieving a pixel alpha value for a UIImage

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

width CGImageGetWidth 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.. 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.. 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 of the image I get non zero values for..

Convert image to grayscale

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

image to grayscale I am trying to convert an image into grayscale in the following way #define bytesPerPixel 4 #define bitsPerComponent 8 unsigned char getBytesForImage UIImage pImage CGImageRef image pImage CGImage NSUInteger width CGImageGetWidth image NSUInteger height.. 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 rawData width.. 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 xCoordinate..

Retrieving a pixel alpha value for a UIImage

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

height CGImageGetHeight image CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB rawData malloc height width 4 bytesPerPixel 4 bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width.. 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.. 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

image to grayscale I am trying to convert an image into grayscale in the following way #define bytesPerPixel 4 #define bitsPerComponent 8 unsigned char getBytesForImage UIImage pImage CGImageRef image pImage CGImage NSUInteger width.. 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.. 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..

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

unsigned char 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.. 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..

CGBitmapContextCreate on the iPhone/iPad

http://stackoverflow.com/questions/2619224/cgbitmapcontextcreate-on-the-iphone-ipad

CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width 4 memset rawData 0 height width 4 NSUInteger bytesPerPixel 4 NSUInteger bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData.. char rawData malloc height width 4 memset rawData 0 height width 4 NSUInteger bytesPerPixel 4 NSUInteger bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow..

clipping a UIImage as per a polygon

http://stackoverflow.com/questions/3667939/clipping-a-uiimage-as-per-a-polygon

would probably be a CGBitmapContext something like this CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceGray size_t bytesPerPixel 1 size_t bytesPerRow bmpWidth bytesPerPixel size_t bmpDataSize bytesPerRow bmpHeight unsigned char bmpData malloc bmpDataSize.. like this CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceGray size_t bytesPerPixel 1 size_t bytesPerRow bmpWidth bytesPerPixel size_t bmpDataSize bytesPerRow bmpHeight unsigned char bmpData malloc bmpDataSize memset bmpData 0 bmpDataSize CGContextRef..

Create a mask from difference between two images (iPhone)

http://stackoverflow.com/questions/3901404/create-a-mask-from-difference-between-two-images-iphone

imageRef CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width 4 NSUInteger bytesPerPixel 4 NSUInteger bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData.. unsigned char rawData malloc height width 4 NSUInteger bytesPerPixel 4 NSUInteger bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow.. context Now your rawData contains the image data in the RGBA8888 pixel format. int byteIndex bytesPerRow yy xx bytesPerPixel for int ii 0 ii count ii CGFloat red rawData byteIndex 1.0 255.0 CGFloat green rawData byteIndex 1 1.0 255.0 CGFloat blue..

Filling a portion of an image with color

http://stackoverflow.com/questions/8124308/filling-a-portion-of-an-image-with-color

imageRef CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width 4 NSUInteger bytesPerPixel 4 NSUInteger bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData.. unsigned char rawData malloc height width 4 NSUInteger bytesPerPixel 4 NSUInteger bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent.. context Now your rawData contains the image data in the RGBA8888 pixel format. int byteIndex bytesPerRow yy xx bytesPerPixel for int ii 0 ii count ii CGFloat red rawData byteIndex 1.0 255.0 CGFloat green rawData byteIndex 1 1.0 255.0 CGFloat blue..