• 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
Re: drawing an array of pixels to the screen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing an array of pixels to the screen


  • Subject: Re: drawing an array of pixels to the screen
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Mon, 12 Nov 2007 16:19:37 +0100


Le 12 nov. 07 à 15:38, Erik Buck a écrit :

There seems to be some confusion.

  In C, the following two arrays are interchangeable:

  int   twoDArray[100][500];
  int   oneDArray[100 * 500];

Both occupy the same amount of memory. They can be cast back and forth harmlessly. Both are of the following assignments are legal and meaningful:

  int   *array = twoDArray;
  int   *array = oneDArray;

Both styles of array decalartion are usable with - initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPe rPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsP erPixel
and with openGL.

It's true only for a fixed size array. The following statement will crash:


int width = 100, height = 500;
int **array = malloc(width * height);
array[50][50] = 0;


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


References: 
 >Re: drawing an array of pixels to the screen (From: Erik Buck <email@hidden>)

  • Prev by Date: Re: How to archive structs like NSRect
  • Next by Date: Re: private MIME type
  • Previous by thread: Re: drawing an array of pixels to the screen
  • Next by thread: Re: drawing an array of pixels to the screen
  • Index(es):
    • Date
    • Thread