unsigned char *BitmapGetBits(int bi);

 

Returns an unsigned char pointer to the pixels at the specified Bitmap handle.

 

Return Value

 

Unsigned char pointer to pixels in Bitmap memory.

 

Parameters

 

bi

Handle to the Bitmap surface to be manipulated.

 

Remarks

 

BitmapGetBits() returns a pointer to the Bitmap memory.  After making changes to the bitmap data returned by this function, be sure to call BitmapUpdate() when you are ready for the Bitmap surface to be rendered with the new data.

 

The pixel data is in native iOS byte order: BGRA.  Each pixel contains four bytes.  The first is blue, followed by green, red and alpha.

 

The following code will access any pixel in the Bitmap data:

 

MyBitmap=BitmapAdd(0,0,320,480);

MyBits=BitmapGetBits(MyBitmap);

...

MyBits[(y*w+x)*4]; //is the 1st byte of a 4 byte pixel at x,y where w is the width of the bitmap surface

blue=MyBits[(y*w+x)*4];

green=MyBits[(y*w+x)*4+1];

red=MyBits[(y*w+x)*4+2];

alpha=MyBits[(y*w+x)*4+3];

 

NOTE:  The pointer returned by this function returns points to an area that is equal to the width times the height of the Bitmap surface times four bytes per pixel. Do not modify memory outside this range.

 

Availability

 

Available in DragonFireSDK 1.3 and later.

 

Example

 

The example below creates a 100 x 100 Bitmap surface and sets its pixels to white with full alpha.

 

#include "DragonFireSDK.h"

#include <string.h>

 

int MyBitmap;

unsigned char *MyBits;

 

void AppMain()

{  

  MyBitmap = BitmapAdd(0, 0, 100, 100);

  MyBits = BitmapGetBits(MyBitmap);

  memset(MyBits, 0xFF, 100*100*4);

  BitmapUpdate(MyBitmap);

}

 

void AppExit()

{

 

}

 

void OnTimer()

{

 

}