In case this is useful for somebody ... I DO NOT claim it to be the best solution to get access to your RGB values from a UIImage.
I have now copied the bytes manually, removing all the alpha bytes. Below is the code (any way to improve that for speed?

:
Here are some more links on the topic of "non-alpha RGB" support (or the lack of it).
CGBitmapContextCreate fails for RGB [Archive] - Mac & iPhone Game Development Forum - iDevGames
Re: CGBitmapContextCreate hates me
Quote:
void *data = CGBitmapContextGetData (context);
if (data != NULL)
{
unsigned char* bitmapData2 = malloc( bitmapByteCountRGB );
if (bitmapData2 == NULL)
{
NSLog(@"Memory not allocated");
return NULL;
}
unsigned char* rcdata = (unsigned char*) data;
unsigned char* wcdata = bitmapData2;
// printf("3:\n");
for (int i = 0 ; i < bitmapByteCount / 4; i++, rcdata += 4)
{
*(wcdata + 0) = *(rcdata + 0);
*(wcdata + 1) = *(rcdata + 1);
*(wcdata + 2) = *(rcdata + 2);
wcdata += 3;
//if (!(i % 10000)) printf("%d[%d] ", i, wcdata);
}
|