I’m sorry for asking this here, but i’m like browsing whole day for this…
How to get an image’s single pixel RGBA and copy it into an array?
And it’s not the whole screen, like using glreadpixel…
my friend in cocos2d iphone use this code to do it…
the CGDataProviderCopyData thing, only do exist in xcode he says…
-(unsigned char**)makeDressMap {
NSString**tempString = [NSString stringWithFormat:`“dress%i.png”,dressID];
UIImage *tempDressImage = [UIImage imageNamed:tempString];int width = (int)tempDressImage.size.width;
int height = (int)tempDressImage.size.height;CCLOG(`“w i",width);
CCLOG(@"h i”,height);
>
unsigned char collisionMap = malloc;
memset;
>
CFDataRef imageData = CGDataProviderCopyData);
const UInt32pixels = (const UInt32*)CFDataGetBytePtr(imageData);
>
for (int j = 0; j<(width*height); j++) {
if (pixels[j] & 0xff000000) {
collisionMap[j] |= 1;
//CCLOG(@“%i”,collisionMap[j]);
}
}
>
CFRelease(imageData);
return collisionMap;
}