iphone中的双缓冲
-(void)drawRect:(CGRect)rect {
NSString* imageName = [[NSString alloc]initWithFormat:@”b%d.png”,m_Index];
UIImage* aImage = [UIImage imageNamed:imageName];
[imageName release];
int width = aImage.size.width;
int height = aImage.size.height;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(nil,width,height,8,0, colorSpace,kCGImageAlphaPremultipliedLast);
CFRelease(colorSpace);
CGContextDrawImage(context, CGRectMake(0, 0, width,height), aImage.CGImage);
CGImageRef image = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage* display = [UIImage imageWithCGImage:image];
[display drawInRect:CGRectMake((480-width)/2, (320-height)/2,width,height)];
}

浙公网安备 33010602011771号