views:

107

answers:

0

I know its possible with boundary fill, but have tried everything in Objective C and I'm still not successful. Any help with code will be highly appreciated.

This code returns the color of the touched pixel:

unsigned char* data = CGBitmapContextGetData (cgctx);
if (data != NULL) { 
    offset = 4*((w*round(point.y))+round(point.x));
    alpha = data[offset];
    red = data[offset+1];
    green = data[offset+2];
    blue = data[offset+3];
    color = [UIColor colorWithRed:(red/255.0f) green:(green/255.0f) blue:(blue/255.0f) alpha:(alpha/255.0f)];}

I am not able to color the pixel, sometimes this code returns different color on the same pixel.