• 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 hates me
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CGBitmapContextCreate hates me


  • Subject: CGBitmapContextCreate hates me
  • From: Jim Turner <email@hidden>
  • Date: Mon, 20 Mar 2006 09:11:19 -0600
  • Thread-topic: CGBitmapContextCreate hates me

I'm trying to write a simple image scaler and from examples I found,
CoreGraphics should be able to do what I need.  The problem arises when I
attempt to create a new bitmap context to write the scaled image into.  The
relevant code:

CGContextRef newImgSetup;
CGImageAlphaInfo alphaInfo;
CGColorSpaceRef colorSpace;
size_t components;
size_t width;
size_t height;
size_t bitsPerComponent;
size_t bytesPerRow;
size_t dataLength;
void *data = NULL;

alphaInfo        = kCGImageAlphaNone;
colorSpace       = CGColorSpaceCreateDeviceRGB();
components       = CGColorSpaceGetNumberOfComponents( colorSpace );
width            = 300;
height           = 250;
bitsPerComponent = 8;
bytesPerRow      = (width * bitsPerComponent * components + 7)/8;
dataLength       = bytesPerRow * height;

data = malloc( dataLength );
memset( data, 0, dataLength );

newImgSetup = CGBitmapContextCreate( data, width, height, bitsPerComponent,
bytesPerRow, colorSpace, alphaInfo );


According to every example I've found, this is supposed to work.  However,
newImgSetup always returns null.  I've verified that data is not null and
that all the variables supplied to CGBitmapContextCreate() are valid and
have appropriate values.  Anyone have any ideas on what's happening here?

--
Jim Turner
email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: CGBitmapContextCreate hates me
      • From: Scott Thompson <email@hidden>
  • Prev by Date: Re: Bindings Faked Array Item Problem
  • Next by Date: Re: Thumbnails
  • Previous by thread: Bindings across multiple Nibs
  • Next by thread: Re: CGBitmapContextCreate hates me
  • Index(es):
    • Date
    • Thread