cocoa - CGBitmapContext get pixel value Leopard vs. SnowLeopard confusion -


I am trying to attract specific color rectangles in a CGBitmapContext and then later I compare the pixel values ​​with color. (A type of hit).

This works fine on leopard, but pixel-values ​​on the snowy pillar are different from the color value I get - I think due to the colors illusion and ignorance are on my part

< P>

  1. Make a bitmap context with a CZG rollerspace generic RGB colorspace
  2. Set the collarspace to the corresponding CGGSpace generic RGB color palette < / Li>
  3. Set the fill color of the reference
  4. Attract
  5. Get the bitmap constantdata, iterative pixel value, and so on.

As an example, if I do, then on Leopard: -

  CGCTXTTRGFillCollar (CNXTX, 1.0, 0.0, 0.0, 1.0); // set pure red fill color CGContextFillRect (cntxt, cntxtBounds); // fill the full reference  

The value in each pixel is UInt8 red == 255, green == 0, blue == 0, alpha == 255

on snow However, the value in each pixel is UInt8 red == 243, green ==31, blue == 6, alpha == 255 (These values ​​are made - I am not on snow leopard anymore. I'm usually specific about that - but definitely it's hard to have correlation with 'red' but for me (1.0,0,0). Similar to other colors (1.0.1.0.1.0) The total will be OK (255,255,255) and (0, 0,0) will be exactly (0,0,0)) .

I have tried other colored spaces, but it does happen.

UPDATE I believe it shows what I'm doing ..

  // create NSUInteger Arbitrary PixSize = 10 ; Size_t component = 4; Size_t bitsactive version = 8; Size_t bytesPerRow = (Manipedixix * bits component component * component +7) / 8; Size_t dataLength = bytesPerRow * Unauthorized Proximity; UInt32 * bitmap = molok (data laugh); MEMSAT (bitmap, 0, data length); CGColorSpaceRef colaspace = CGColorSpaceCreativeWithName (KCG ollerspace genericRGB); CGContextRef Reference = CGBitmapContextCreate (bitmap, manipulation-size, manipulation, bits, biometry, colaspace, KCGImz olfofmilmentplidfast); CGContextSetFillColorSpace (Reference, Callspace); CGContextSetStrokeColorSpace (Reference, Callspace); // - Attract some CGContactSatGraphFillColor (Reference, 1.0F, 0.0F, 0.0F, 1.0F); CGContextFillRect (Reference, CGRectMake (0, 0, ManipulatePix Size, Arbitrary PixSize)); // Test the first pixel UInt8 * baseAddr = (UInt8 *) CGBitmapContextGetData (reference); UInt8 alpha = baidadder [0]; UInt8 red = baseAddr [1]; UInt8 Green = BaseEdder [2]; UInt8 Blue = Bidder [3]; CGContextRelease (reference); CGColorSpaceRelease (colSpace);  

Results

Leopard -> Red == 255, Green == 0, Blue == 0, Alpha == 255

Snow Leopard -> Red == 228, Green == 29, Blue == 29, Alpha == 255

Take a look at the docs for CGContextSetRGBFillColor.

CGContextSetRGBFillColor sets the current fill color to the value in the device RGG color space.

Because of the generic RGB space you wanted your components, use one of the other ways to set the fill color.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -