¡@

Home 

2014/10/15 ¤U¤È 10:05:13

iphone Programming Glossary: colorspace

Retrieving a pixel alpha value for a UIImage

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

NSUInteger width CGImageGetWidth image NSUInteger height CGImageGetHeight image CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB rawData malloc height width 4 bytesPerPixel 4 bytesPerRow bytesPerPixel.. 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage.. bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake 0 0 width height image CGContextRelease context I then calculate..

Convert image to grayscale

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

height CGImageGetHeight image NSUInteger bytesPerRow bytesPerPixel width CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width 4 CGContextRef context CGBitmapContextCreate.. 4 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage.. bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake 0 0 width height image CGContextRelease context return rawData..

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

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 pixelData The pixel.. self.size.height Create RGB color space self setColorSpace CGColorSpaceCreateDeviceRGB if colorSpace NSLog @ Error allocating color space. return nil self setPixelData malloc byteCount if pixelData NSLog.. if pixelData NSLog @ Error allocating bitmap memory. Releasing color space. CGColorSpaceRelease colorSpace return nil Create the bitmap context. Pre multiplied RGBA 8 bits per component. The source image format..

Rounded UIView using CALayers - only some corners - How?

http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how

img UIImage imageNamed @ my_image.png int w img.size.width int h img.size.height CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate NULL w h 8 4 w colorSpace kCGImageAlphaPremultipliedFirst.. colorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate NULL w h 8 4 w colorSpace kCGImageAlphaPremultipliedFirst CGContextBeginPath context CGRect rect CGRectMake 0 0 w h addRoundedRectToPath.. imageMasked CGBitmapContextCreateImage context CGContextRelease context CGColorSpaceRelease colorSpace img release return UIImage imageWithCGImage imageMasked Don't forget that you'll need to get the QuartzCore..

Round two corners in UIView

http://stackoverflow.com/questions/4847163/round-two-corners-in-uiview

CGFloat radius_tr CGFloat radius_bl CGFloat radius_br CGContextRef context CGColorSpaceRef colorSpace colorSpace CGColorSpaceCreateDeviceRGB create a bitmap graphics context the size of the image context.. radius_tr CGFloat radius_bl CGFloat radius_br CGContextRef context CGColorSpaceRef colorSpace colorSpace CGColorSpaceCreateDeviceRGB create a bitmap graphics context the size of the image context CGBitmapContextCreate.. the size of the image context CGBitmapContextCreate NULL rect.size.width rect.size.height 8 0 colorSpace kCGImageAlphaPremultipliedLast free the rgb colorspace CGColorSpaceRelease colorSpace if context NULL..

Retrieving a pixel alpha value for a UIImage

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

this. Alpha is premultiplied. CGImageRef image uiImage.CGImage NSUInteger 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.. 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.. CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake 0 0 width height image CGContextRelease context I then calculate the array index for the given alpha channel using the coordinates..

Convert image to grayscale

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

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 height bitsPerComponent bytesPerRow.. 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.. CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake 0 0 width height image CGContextRelease context return rawData UIImage processImage UIImage pImage DebugLog @ processing image..

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

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 pixelData The pixel struct with alpha in this version typedef struct RGBAPixel.. bytesPerRow self.size.height self setPixelCount self.size.width self.size.height Create RGB color space self setColorSpace CGColorSpaceCreateDeviceRGB if colorSpace NSLog @ Error allocating color space. return nil self setPixelData malloc byteCount if pixelData NSLog @ Error allocating bitmap memory. Releasing color space... color space. return nil self setPixelData malloc byteCount if pixelData NSLog @ Error allocating bitmap memory. Releasing color space. CGColorSpaceRelease colorSpace return nil Create the bitmap context. Pre multiplied RGBA 8 bits per component. The source image format will be converted to the format specified here by CGBitmapContextCreate...

Rounded UIView using CALayers - only some corners - How?

http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how

CGContextRestoreGState context UIImage setImage UIImage img UIImage imageNamed @ my_image.png int w img.size.width int h img.size.height CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate NULL w h 8 4 w colorSpace kCGImageAlphaPremultipliedFirst CGContextBeginPath context CGRect.. int w img.size.width int h img.size.height CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate NULL w h 8 4 w colorSpace kCGImageAlphaPremultipliedFirst CGContextBeginPath context CGRect rect CGRectMake 0 0 w h addRoundedRectToPath context rect 50 1 CGContextClosePath context CGContextClip.. context CGContextDrawImage context rect img.CGImage CGImageRef imageMasked CGBitmapContextCreateImage context CGContextRelease context CGColorSpaceRelease colorSpace img release return UIImage imageWithCGImage imageMasked Don't forget that you'll need to get the QuartzCore framework in there for this to work. share improve..

Round two corners in UIView

http://stackoverflow.com/questions/4847163/round-two-corners-in-uiview

UIImage MTDContextCreateRoundedMask CGRect rect CGFloat radius_tl CGFloat radius_tr CGFloat radius_bl CGFloat radius_br CGContextRef context CGColorSpaceRef colorSpace colorSpace CGColorSpaceCreateDeviceRGB create a bitmap graphics context the size of the image context CGBitmapContextCreate NULL rect.size.width rect.size.height.. CGRect rect CGFloat radius_tl CGFloat radius_tr CGFloat radius_bl CGFloat radius_br CGContextRef context CGColorSpaceRef colorSpace colorSpace CGColorSpaceCreateDeviceRGB create a bitmap graphics context the size of the image context CGBitmapContextCreate NULL rect.size.width rect.size.height 8 0 colorSpace.. CGColorSpaceCreateDeviceRGB create a bitmap graphics context the size of the image context CGBitmapContextCreate NULL rect.size.width rect.size.height 8 0 colorSpace kCGImageAlphaPremultipliedLast free the rgb colorspace CGColorSpaceRelease colorSpace if context NULL return NULL cerate mask CGFloat minx CGRectGetMinX rect midx..

Retrieving a pixel alpha value for a UIImage

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

image uiImage.CGImage NSUInteger width CGImageGetWidth image NSUInteger height CGImageGetHeight image CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB rawData malloc height width 4 bytesPerPixel 4 bytesPerRow bytesPerPixel width NSUInteger bitsPerComponent.. bitsPerComponent 8 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake.. bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake 0 0 width height image CGContextRelease context I then calculate the array index for..

Convert image to grayscale

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

image NSUInteger height CGImageGetHeight image NSUInteger bytesPerRow bytesPerPixel width CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB unsigned char rawData malloc height width 4 CGContextRef context CGBitmapContextCreate rawData.. malloc height width 4 CGContextRef context CGBitmapContextCreate rawData width height bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake.. bitsPerComponent bytesPerRow colorSpace kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big CGColorSpaceRelease colorSpace CGContextDrawImage context CGRectMake 0 0 width height image CGContextRelease context return rawData UIImage processImage..

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

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 pixelData The pixel struct with alpha in.. self.size.width self.size.height Create RGB color space self setColorSpace CGColorSpaceCreateDeviceRGB if colorSpace NSLog @ Error allocating color space. return nil self setPixelData malloc byteCount if pixelData NSLog @ Error allocating.. malloc byteCount if pixelData NSLog @ Error allocating bitmap memory. Releasing color space. CGColorSpaceRelease colorSpace return nil Create the bitmap context. Pre multiplied RGBA 8 bits per component. The source image format will be converted..

Rounded UIView using CALayers - only some corners - How?

http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how

setImage UIImage img UIImage imageNamed @ my_image.png int w img.size.width int h img.size.height CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate NULL w h 8 4 w colorSpace kCGImageAlphaPremultipliedFirst.. CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB CGContextRef context CGBitmapContextCreate NULL w h 8 4 w colorSpace kCGImageAlphaPremultipliedFirst CGContextBeginPath context CGRect rect CGRectMake 0 0 w h addRoundedRectToPath context rect.. img.CGImage CGImageRef imageMasked CGBitmapContextCreateImage context CGContextRelease context CGColorSpaceRelease colorSpace img release return UIImage imageWithCGImage imageMasked Don't forget that you'll need to get the QuartzCore framework in..

Round two corners in UIView

http://stackoverflow.com/questions/4847163/round-two-corners-in-uiview

rect CGFloat radius_tl CGFloat radius_tr CGFloat radius_bl CGFloat radius_br CGContextRef context CGColorSpaceRef colorSpace colorSpace CGColorSpaceCreateDeviceRGB create a bitmap graphics context the size of the image context CGBitmapContextCreate.. radius_tl CGFloat radius_tr CGFloat radius_bl CGFloat radius_br CGContextRef context CGColorSpaceRef colorSpace colorSpace CGColorSpaceCreateDeviceRGB create a bitmap graphics context the size of the image context CGBitmapContextCreate NULL rect.size.width.. bitmap graphics context the size of the image context CGBitmapContextCreate NULL rect.size.width rect.size.height 8 0 colorSpace kCGImageAlphaPremultipliedLast free the rgb colorspace CGColorSpaceRelease colorSpace if context NULL return NULL cerate..

How to change thin image to fat image in iPhone SDK?

http://stackoverflow.com/questions/10186200/how-to-change-thin-image-to-fat-image-in-iphone-sdk

size_t bitsPerPixel CGImageGetBitsPerPixel imageRef size_t bytesPerRow CGImageGetBytesPerRow imageRef CGColorSpaceRef colorspace CGColorSpaceCreateDeviceRGB CGBitmapInfo bitmapInfo CGImageGetBitmapInfo imageRef CGDataProviderRef provider CGDataProviderCreateWithData.. pixels data length NULL CGImageRef newImageRef CGImageCreate width height bitsPerComponent bitsPerPixel bytesPerRow colorspace bitmapInfo provider NULL false kCGRenderingIntentDefault the modified image UIImage newImage UIImage imageWithCGImage newImageRef..

iPhone: Changing CGImageAlphaInfo of CGImage

http://stackoverflow.com/questions/2457116/iphone-changing-cgimagealphainfo-of-cgimage

reading CGBitmapContextCreate unsupported parameter combination 8 integer bits component 32 bits pixel 3 component colorspace kCGImageAlphaLast 1344 bytes row. The list of supported pixel formats definitely does not support this combination. It appears..

Extracting images from a PDF

http://stackoverflow.com/questions/2475450/extracting-images-from-a-pdf

CGColorSpaceCreateDeviceGray CGColorSpaceCreateWithName kCGColorSpaceGenericGray spp 1 else if bps 1 if there's no colorspace entry there's still one we can infer from bps cgColorSpace CGColorSpaceCreateDeviceGray colorSpace NSDeviceBlackColorSpace..

UIImage rounded corners

http://stackoverflow.com/questions/262156/uiimage-rounded-corners

NULL targetSize.width targetSize.height 8 0 colorSpace kCGImageAlphaPremultipliedLast free the rgb colorspace CGColorSpaceRelease colorSpace if mainViewContentContext NULL return NULL CGContextSetFillColorWithColor mainViewContentContext..

Convert Image to B&W problem CGContext - iPhone Dev

http://stackoverflow.com/questions/3340564/convert-image-to-bw-problem-cgcontext-iphone-dev

CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceGray Create bitmap content with current image size and grayscale colorspace CGContextRef context CGBitmapContextCreate nil image.size.width image.size.height 8 0 colorSpace kCGImageAlphaNone Draw.. Draw image into current context with specified rectangle using previously defined context with grayscale colorspace CGContextDrawImage context imageRect image CGImage Create bitmap image info from pixel data in current context CGImageRef.. context Create a new UIImage object UIImage newImage UIImage imageWithCGImage imageRef Release colorspace context and bitmap information CGColorSpaceRelease colorSpace CGContextRelease context CFRelease imageRef Return the new..

How to display an image on a MKOverlayView?

http://stackoverflow.com/questions/3891850/how-to-display-an-image-on-a-mkoverlayview

imageReference self.scaleFactor size_t height CGImageGetHeight imageReference self.scaleFactor Calculate colorspace for the specified image CGColorSpaceRef imageColorSpace CGImageGetColorSpace imageReference Allocate and clear memory for.. CGRectMake 0 0 width height else imageRect CGRectMake 0 0 height width Create the imagecontext by defining the colorspace and the address of the location to store the data CGContextRef imageContext CGBitmapContextCreate imageData width height..

What's the correct code to save a CGLayer as a PNG file?

http://stackoverflow.com/questions/4064470/whats-the-correct-code-to-save-a-cglayer-as-a-png-file

associated with drawing to the screen normally. UIGraphicsGetCurrentContext also normally works but you could have colorspace woes so create the CGLayer called notepad... CGLayerRef notepad CGLayerCreateWithContext yourContext CGSizeMake 1500 1500.. smallTestImage ofType @ png CGImage CGContextDrawImage notepadContext CGRectMake 100 100 50 50 imageExamp setting the colorspace may or may not be relevant to you CGContextSetFillColorSpace notepadContext CGColorSpaceCreateDeviceRGB you can draw to..

Round two corners in UIView

http://stackoverflow.com/questions/4847163/round-two-corners-in-uiview

CGBitmapContextCreate NULL rect.size.width rect.size.height 8 0 colorSpace kCGImageAlphaPremultipliedLast free the rgb colorspace CGColorSpaceRelease colorSpace if context NULL return NULL cerate mask CGFloat minx CGRectGetMinX rect midx CGRectGetMidX..

iPhone CGContextRef CGBitmapContextCreate unsupported parameter combination

http://stackoverflow.com/questions/5545600/iphone-cgcontextref-cgbitmapcontextcreate-unsupported-parameter-combination

Filling a portion of an image with color

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

Here i'm struggling to paint the remaining section. BOOL cgHitTestForArea CGRect area BOOL hit FALSE CGColorSpaceRef colorspace CGColorSpaceCreateDeviceRGB float areaFloat area.size.width 4 area.size.height unsigned char bitmapData malloc areaFloat.. context CGBitmapContextCreate bitmapData area.size.width area.size.height 8 4 area.size.width colorspace kCGImageAlphaPremultipliedLast CGContextTranslateCTM context area.origin.x area.origin.y self.layer renderInContext context.. transparentPixels areaFloat if transparentPixels areaFloat 4 hitTolerance hit TRUE CGColorSpaceRelease colorspace CGContextRelease context return hit Any suggestions to make this work please iphone ios share improve this question ..