Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-11-2008, 01:01 AM   #10 (permalink)
stevebee
New Member
 
Join Date: Sep 2008
Posts: 3
Default

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);
}
stevebee is offline   Reply With Quote
 

» Advertisements
» Online Users: 874
21 members and 853 guests
ADY, anshuk1219, chits12345, dabvid, dfvdan, donlucacorleone, dreamer11, FAED, gmarro, Grinarn, honeybutterfly, ilmman, IQ8Y1, john love, M@realobjects, Nicoloren, nobre84, RoryHarvey, sethaver, snackbox, VikMyr
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,866
Threads: 89,225
Posts: 380,691
Top Poster: BrianSlick (7,129)
Welcome to our newest member, sethaver
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:14 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.