본문 바로가기

프로그램 경험/iOS

[iPhone] 이미지 가져와서 그리기

CGContextRef context = UIGraphicsGetCurrentContext();

NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"imagefile.bmp" ofType:nil];
UIImage *img = [UIImage imageWithContentsOfFile:imagePath];
CGImageRef image = CGImageRetain(img.CGImage);


CGRect imageRect;
imageRect.origin = CGPointMake(15.0, 15.0);
imageRect.size = CGSizeMake(25.0, 25.0);

CGContextDrawImage(context, imageRect, image);