• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CGBitmapContextCreate fo Lab colorSpace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CGBitmapContextCreate fo Lab colorSpace


  • Subject: CGBitmapContextCreate fo Lab colorSpace
  • From: "Barry" <email@hidden>
  • Date: Thu, 14 Jun 2007 15:21:31 +0100

Can anyone see what's wrong here ?
I always get "Context not created!".


CGContextRef CreateBitmapContext (CGImageRef inImage) { CGContextRef context = NULL; CGColorSpaceRef colorSpace; void * bitmapData; int bitmapByteCount; int bitmapBytesPerRow; float whitePoint[3]={0.95, 1.0, 1.09}; float blackPoint[3]={0,0,0}; float range[4]={-127,127,-127,127};

   size_t pixelsWide = CGImageGetWidth(inImage);
   size_t pixelsHigh = CGImageGetHeight(inImage);

   bitmapBytesPerRow   = (pixelsWide * 3);
   bitmapByteCount     = (bitmapBytesPerRow * pixelsHigh);

   colorSpace = CGColorSpaceCreateLab(whitePoint, blackPoint, range);
   if (colorSpace == NULL)
   {
       fprintf(stderr, "Error allocating color space\n");
       return NULL;
   }

    bitmapData = malloc( bitmapByteCount );
   if (bitmapData == NULL)
   {
       fprintf (stderr, "Memory not allocated!");
       CGColorSpaceRelease( colorSpace );
       return NULL;
   }

   context = CGBitmapContextCreate (bitmapData,
                                   pixelsWide,
                                   pixelsHigh,
                                   8,
                                   bitmapBytesPerRow,
                                   colorSpace,
                                   kCGImageAlphaNone);
   if (context == NULL)
   {
       free (bitmapData);
       fprintf (stderr, "Context not created!");
   }

   CGColorSpaceRelease( colorSpace );
   return context;
}

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: CGBitmapContextCreate fo Lab colorSpace
      • From: Steve Christensen <email@hidden>
  • Prev by Date: Re: Creating a plugin bundle for Mail.app using Cocoa
  • Next by Date: Re: -[NSPredicate evaluateWithObject:] and NSArray
  • Previous by thread: Editing single cell from multiple cells in an customized NSTableView Column.
  • Next by thread: Re: CGBitmapContextCreate fo Lab colorSpace
  • Index(es):
    • Date
    • Thread