Saturday, March 7, 2009

UIImage

UIImage   *bgImage = [UIImage imageNamed:@"ume_bg.png"]; // 320*480 PNG

CFDataRef bgImageData = CGDataProviderCopyData(CGImageGetDataProvider(bgImage.CGImage));


//int length = CFDataGetLength(bgImageData); //480*320*3

//size_t height = CGImageGetHeight(bgImage.CGImage); //480

//size_t width =  CGImageGetWidth(bgImage.CGImage);  //320

//size_t a1 = CGImageGetBitsPerComponent(bgImage.CGImage); //8

//size_t a2 = CGImageGetBitsPerPixel(bgImage.CGImage); //24 = 8 * 3(R G B)

//size_t a3 = CGImageGetBytesPerRow(bgImage.CGImage); //960 = 320 * 3(R G B)

const UInt8 *bgByte = CFDataGetBytePtr(bgImageData); // raw data


// get RGB data at position pos

int r = bgByte[pos];

int g = bgByte[pos+1];

int b = bgByte[pos+2];


/*

NSString *msg = [[NSString alloc] initWithFormat:@"pos(x:%d, y:%d) (%d, %d, %d)", xx, yy, r, g, b];

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@"(x,y)"

message:msg

delegate:self

cancelButtonTitle:@"Phew!"

otherButtonTitles:nil];

[alert show];

[msg release];

[alert release];

*/

/*

UIImageView *umeView = [[UIImageView alloc] initWithFrame:CGRectMake(point.x, point.y-31, 42.0, 62.0)];

//load all the frames of ume animation

umeView.animationImages = [NSArray arrayWithObjects:

[UIImage imageNamed:@"ume_1.PNG"],

[UIImage imageNamed:@"ume_2.PNG"],

[UIImage imageNamed:@"ume_3.PNG"], nil];

umeView.animationDuration = 0.5;

umeView.animationRepeatCount = 0;

[umeView startAnimating];

[self.view addSubview:umeView];

[umeView stopAnimating];

[umeView release];

*/

No comments:

Post a Comment