私は次のようにプログラムで UIImage に描画しようとしています:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIGraphicsBeginImageContextWithOptions(CGSizeMake(2, 2), YES, 1);
CGContextRef context = UIGraphicsGetCurrentContext();
// These three lines of code apparently do nothing.
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
CGContextSetAllowsAntialiasing(context, false);
CGContextSetShouldAntialias(context, false);
CGContextSetFillColorWithColor(context, [UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor);
CGContextFillRect(context, CGRectMake(0, 0, 1, 1));
self.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
このコードは、明らかにアンチエイリアシング/補間の積極的な試みにより、結果の画像が非常にソフトになることを除けば機能します。最近傍補間を使用して画像をスケーリングする必要があります。このアンチエイリアシングを防ぐにはどうすればよいですか?
ありがとうございました!